JSOM in SharePoint

 JSOM (JavaScript Object Model) is a set of APIs that allows developers to access and manage Microsoft SharePoint content and data from JavaScript code. JSOM is designed to be used in client-side scenarios where the server-side API (such as the Server Object Model or the REST API) is not available or not appropriate.


With JSOM, you can access and manipulate SharePoint objects such as lists, libraries, web sites, and users, as well as execute common actions such as adding, updating, and deleting data. You can also use JSOM to access and query data from external sources, and to integrate SharePoint with other systems and applications.


To use JSOM in your application, you will need to include the appropriate script files in your HTML page, and then reference the namespaces and objects that you want to use. You can find detailed documentation and examples of how to use JSOM on the Microsoft developer website.


JSOM is a powerful and flexible tool that allows you to build custom solutions for SharePoint using JavaScript. It is especially useful for building client-side applications that run in the web browser, such as web parts or apps for Office. I hope this helps! Let me know if you have any other questions about JSOM or SharePoint development.


Here are some additional details about JSOM:


  • JSOM is designed to be lightweight and efficient, with a small footprint and minimal overhead. It is intended for use in client-side scenarios where the server-side API (such as the Server Object Model or the REST API) is not available or not appropriate.

  • JSOM is available for SharePoint on-premises and SharePoint Online. You can use the same API to access and manage SharePoint data and content across both deployment models, and you can use the same authentication and authorization mechanisms to secure your applications.

  • JSOM is designed to be easy to use and flexible, with a rich object model that allows you to access and manipulate a wide range of SharePoint objects and data. You can use JSOM to perform common tasks such as creating and deleting sites, lists, and libraries; adding, updating, and deleting list items and documents; and managing users and permissions.

  • JSOM supports both synchronous and asynchronous programming models, so you can choose the approach that best fits your needs. You can use the synchronous model to execute commands and queries in a blocking manner, or the asynchronous model to execute them in a non-blocking manner.
Here is a simple example of how you can use JSOM in a web page to retrieve and display the title of the current SharePoint site:



This code includes the "sp.js" script file, which contains the JSOM library, and then uses the "SP.ClientContext" object to connect to the SharePoint site and retrieve the current "Site" object. It loads the "Title" property of the site and executes the query, and then displays the title of the site in the console.

 Here is another example of how you can use JSOM to retrieve and display a list of items from a SharePoint list:



This code includes the "sp.js" script file, and then uses the "SP.ClientContext" object to connect to the SharePoint site and retrieve a "List" object by its title. It creates a query using the "SP.CamlQuery" object to retrieve all items in the list, and loads the "items" collection. Finally, it executes the query and iterates through the items, displaying the value of the "Title" field for each item.

0 Comments