sharepoint client object model tutorial

sharepoint online client object model tutorial

We can use client object model code to retrieve, update, insert and manage data in SharePoint 2016/2013 or SharePoint online. SharePoint Online or SharePoint 2016/2013 provides various client object model like below:
– Managed Client Object Model (csom)
– JavaScript Client Object Model (jsom)
– Rest API for SharePoint
– Silverlight client object model
– Windows Phone Assemblies

Microsoft provides various dlls or js file to work with SharePoint. To work with managed client object model we have to use two ddls which can be found in ISAPI (E:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\) folder.
– Microsoft.SharePoint.Client.dll
– Microsoft.SharePoint.Client.Runtime.dll

sharepoint online client object model tutorial
SharePoint online client object model tutorial

To work with Silverlight client object model, we have to use below two dlls which are found in LAYOUTS\ClientBin folder.
– Microsoft.SharePoint.Client.Silverlight.dll
– Microsoft.SharePoint.Client.Silverlight.Runtime.dll






Similarly to work with JavaScript Object model we have to use SP.js file which is located in the LAYOUTS folder.

Check out various SharePoint javascript object model (jsom) examples.

While each of the models provides a different programming interface, each interacts with SharePoint through a Windows Communication Foundation (WCF) service named Client.svc, which is located in the ISAPI directory.

sharepoint 2013 client object model tutorial
sharepoint 2013 client object model tutorial

Developers write client-side code using the object model, but the operations are batched and sent as a single Extensible Markup Language (XML) request to the Client.svc service. When the XML request is received, the Client.svc service makes calls to the server-side object model on behalf of the client. The results of the server-side calls are then sent back to the calling client in the form of a JavaScript Object Notation (JSON) object.




Also read: SharePoint Rest API Tutorials

Before starting look at the classes below:

Working with Contexts:

Server side object model or client side object model requires a starting point to work with SharePoint objects. The starting point is known as contexts.

The context object provides an entry point into the associated application programming interface (API) that can be used to gain access to other objects. Once you have access to the objects, you may interact with the scalar properties of the object like Name, Title, Url etc. freely.

The ClientContext class in both the managed and Silverlight object models inherits from the ClientContextRuntime class.

The SP.ClientContext class in the JavaScript client object model inherits from the SP.Client ContextRuntime class.

The ClientContextRuntime class provides two methods for loading objects: Load and LoadQuery.
The Load method specifies an object or collection to retrieve, while the LoadQuery method allows you to return collections of objects using a LINQ query.

Executing the Load or LoadQuery method does not cause the client to communicate with the server. Instead, it adds the load operation to a batch that will be executed on the server. In fact, you may execute multiple load methods (as well as other operations) before calling the server. Each operation is batched, waiting for your code to initiate communication with the server. To execute the batched operations, your code must call the ExecuteQuery or ExecuteQueryAsync method. The ExecuteQuery method creates an XML request and passes it to the Client.svc service. The client then waits synchronously while the batch is executed and the JSON results are returned. The ExecuteQueryAsync method, which is used in the Silverlight client object model, sends the XML request to the server, but it returns immediately. Designated success and failure callback methods receive notification when the batch operation is complete.


About Bijay Kumar

I am Bijay from Odisha, India. Currently working with a reputed organization in Bangalore. I am Microsoft Office Servers and Services (SharePoint) MVP (4 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.

View all posts by Bijay Kumar →

Leave a Reply

Your email address will not be published. Required fields are marked *