Hi Just a quick question on when to use CSOM and JSOM.

I've created a page using SPD and want to retrieve list items. I assume I should use JSOM for this however can I use CSOM code also?

If I create an independent application(i.e. page not residing in sharepoint) then I cannot use JSOM and have to use CSOM.

Could someone kindly validate the above?

  • I can only say, you are correct :) – Arsalan Adam Khatri Nov 11 '14 at 9:47
  • With CSOM, I can use Visaul Studio, however assemlies are missing (Microsoft.SharePoint.Client assembly and Microsoft.SharePoint.Client.Runtime). A blog suggests dowloading and adding to my VS client machine. If I do this then will the solution be portable? – Orange Juice Jones Nov 11 '14 at 10:03
  • Do you have SharePoint installed on the machine? If yes, you can find the dll's in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI (14/15 based on SharePoint version). If not how will you test what you have developed? – Arsalan Adam Khatri Nov 11 '14 at 10:13
  • I dont have sharepoint installed on the machine. I'm planning to create a Console Application, I think this should work once I have referenced the dll's. – Orange Juice Jones Nov 11 '14 at 10:27
  • Yes it will work once you reference the dll's, but how will you test it? :) – Arsalan Adam Khatri Nov 11 '14 at 10:36

The term 'Client-Side Object Model' encompasses the C# (often called CSOM, or sometimes Managed CSOM) and the JavaScript (JSOM) versions of two Client-Side APIs for working with SharePoint.

The answer of which to use depends upon where you want to use it...

To use the Managed CSOM, you need to be able to deploy managed code, this limits you to: farm/full trust solutions, sandbox solutions (where custom code such as this is deprecated going forward), and Provider Hosted SharePoint Apps.

The JSOM can work anywhere you have SharePoint loading in the browser, this includes: all types of SharePoint Apps, JSLink files that render list views on your host site, directly on any SharePoint page via editting the source (such as with SPD/VS/Dream Weaver/etc) or using a web part that supports rendering scripts/HTML.

There are pros and cons to each scenario, but this highlights when you could use each approach. A prime example from the comments above -- interactive debugging for managed code requires a local installation (a SharePoint instance or an ASP.NET application running as a provider hosted app are two typical examples); debugging JavaScript just requires some knowledge of how to use the dev tools in your favorite browser.

It's worth noting that the REST API is also available using managed C#, JavaScript, and many other language stacks (Python, Java, etc.)

And something else I just thought of: you can probably use the JSOM in a node.js application as well, but I've never heard of anyone actually doing so...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.