sharepoint Working with JavaScript Client Object Model (JSOM)

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9



The JavaScript Object Model was introduced in SharePoint 2010. It exposes on the client side many of the objects that were previously only accessible through server-side code or through dedicated web services.

Embedding JavaScript in SharePoint Pages

In SharePoint 2013 you can put your JavaScript in a Script Editor web part.

In SharePoint 2010 you can use the "content link" property of a Content Editor web part to link to an HTML file that contains your embedded script.

Object Reference

The constructors, methods, and properties of all objects found in the SP namespace are documented in the SharePoint 2013 client object model reference here.

The SharePoint 2010 JavaScript client object model reference is available here.

JSOM's Asynchronous Programming Pattern

When using the JavaScript client object model, code generally takes the following pattern:

  1. Obtain a ClientContext object.
  2. Use the ClientContext object to retrieve objects representing entities in the SharePoint object model, such as lists, folder, views.
  3. Queue up instructions to be performed against the objects. These instructions are not transmitted to the server yet.
  4. Use the load function to tell the ClientContext what information you want to receive back from the server.
  5. Invoke the ClientContext object's executeQueryAsync function to send the queued instructions to the server, passing two callback functions to run on success or failure.
  6. In the callback function, work with the results returned from the server.


Client-side alternatives to the JSOM include SharePoint's web services, REST endpoints, and the .NET client object model.

Got any sharepoint Question?