Search This Blog

Thursday, April 11, 2019

Comparison (cookies vs cache), (PUT vs POST) && (JSLink vs Script Editor vs Content Editor WebPart)

cookies vs cache

Cookie should be used to store per-user information for the current Web session or persistent information on the client, therefore client has control over the contents of a cookie.

Cache object is shared between users in a single application. Its primary purpose is to cache data from a data store and should not be used as a primary storage. It supports automatic invalidation features.

PUT vs POST

The most commonly used HTTP verbs POST, GET, PUT, DELETE are similar to CRUD (Create, Read, Update and Delete) operations in database. We specify these HTTP verbs in the capital case. So, the below is the comparison between them.

create - POST
read - GET
update - PUT
delete - DELETE
PATCH: Submits a partial modification to a resource. If you only need to update one field for the resource, you may want to use the PATCH method.

JSLink vs Script Editor vs Content Editor WebPart

1. JSlink: you can control rendering of Fields, Items and even Web Parts using a JavaScript File referenced in JS Link property field of a Web Part.

2.  Script Editor Web Part: you could paste your html and JavaScript into Script Editor Web Part. And it is a reusable one.

3. Content Editor Web Part: you could add formatted text, tables, hyperlinks, and images to a Web Part Page by Content Editor Web Part.

Difference between Sandboxed and Farm solution

In this post we will see the difference between Farm solutions and Sandboxed solutions 

Farm solutions, which are hosted in the IIS worker process (W3WP.exe), run code that can affect the whole farm. 

Sandboxed solutions, which are hosted in the SharePoint user code solution worker process (SPUCWorkerProcess.exe), run code that can only affect the site collection of the solution.Farm solutions are installed and deployed. Sandboxed solutions are uploaded and activated.

Embed code and script editor webpart in SharePoint 2013

In this post, we will discuss some difference between the Embed code and Script editor web part in SharePoint 2013.

Both Embed code and Script editor web part are new in SharePoint 2013. You can include JavaScript and HTML contents through the Embed Code which you will get when edit a site page and this is located under Insert Tab in the Ribbon.

Script editor web part also you can use to paste your HTML and JavaScript into the page. But it is a reusable one. The difference between these two is Embed code is not reusable.

Another major difference between these two is Embed code allows you to place the Iframe elements but Script Editor Web Part doesn’t allow. So Youtube, Twitter or LinkedIn or Facebook code you can paste through Embed Code.

Wednesday, April 10, 2019

How To Get All SharePoint List Item Versions Using CSOM For Custom List And Document Library

In CSOM, basically, there is no direct property to get the versions of the items in a List. By using "Lists Web Service"(/_vti_bin/Lists.asmx), however, we can get the information of all the versions and properties of each item inside a Custom List or a Document Library.
To get the above-required functionality, first of all, we have added the "Lists Web Service" in the required project.
In this blog, I am going to share all the codes for getting the version details of list items by using "Lists Web Service". We all know how to add a service to a project.
We are using the below code to achieve the same. The code is self-explanatory because of the comments I have written before each snippet.

Source Code

using System;
using System.Net;
using System.Xml;
using Microsoft.SharePoint.Client;
namespace ConsoleAppTest {
    class Program {
        static void Main(string[] args) {
            ClientContext context = null;
            List list = null;
            ListItemCollection itemCollection = null;
            ListItem item = null;
            string userName = string.Empty;
            string password = string.Empty;
            string dateHistory = string.Empty;
            string commentHistory = string.Empty;
            string editor = string.Empty;
            string loginName = string.Empty;
            try {
                using(context = new ClientContext("https://Testsite.sharepoint.com")) {
                    userName = "UserName";
                    password = "PassWord";
                    // Setting credential for the above site
                    context.Credentials = new SharePointOnlineCredentials(userName, password);
                    context.Load(context.Web);
                    context.ExecuteQuery();
                    // Getting list by Title
                    list = context.Web.Lists.GetByTitle("List Title");
                    context.Load(list, L => L.Id);
                    // Getting all items from selected list using caml query
                    itemCollection = list.GetItems(CamlQuery.CreateAllItemsQuery());
                    //Loading selected list items
                    context.Load(itemCollection, IC => IC.Include(I => I.Id, I => I.DisplayName));
                    context.ExecuteQuery();
                    if (itemCollection != null && itemCollection.Count > 0) {
                        for (int iCount = 0; iCount < itemCollection.Count; iCount++) {
                            try {
                                item = itemCollection[iCount];
                                ListService.Lists listService = new ListService.Lists();
                                listService.Url = context.Url + "/_vti_bin/Lists.asmx";
                                listService.Credentials = context.Credentials;
                                //Getting all item versions from custon list item using List Web Service
                                XmlNode nodeVersions = listService.GetVersionCollection(list.Id.ToString(), item.Id.ToString(), "_UIVersionString");
                                //looping all versions and getting 'Modified' and 'Editor' property of each version
                                foreach(XmlNode xNode in nodeVersions) {
                                    try {
                                        dateHistory = xNode.Attributes["Modified"].Value;
                                        dateHistory = FormatDateFromSP(dateHistory);
                                        commentHistory = xNode.Attributes["_UIVersionString"].Value;
                                        loginName = xNode.Attributes["Editor"].Value;
                                    } catch {}
                                }
                            } catch (Exception ex) {}
                        }
                    }
                }
            } catch (Exception ex) {}
        }

        private static string FormatDateFromSP(string dateHistory) {
            string result;
            result = dateHistory.Replace("T", " ");
            result = result.Replace("Z", "");
            return result;
        }
    }
}   

Tuesday, April 9, 2019

Site Pages and Application Pages in SharePoint 2013

Site Pages
  
                   These Pages are stored in the Content Database and they are parsed when requested by user. A typical web part page is an example of Site Pages. They can be edited, modified by the Power Users and customized according to their needs.

Application Pages

                  They are same as ASP.net Pages and stored on the layouts folder of SharePoint front end web server. When user requests , application pages are compiled and they are much faster than Site Pages. Admin Pages like settings.aspx, accessdenied.aspx are an example of Application Pages. Thus we can say that Application pages are common to all SharePoint Users.