JSOM: Get all content types from SharePoint web

How to retrieve the collection of content types from the SharePoint sub site? There is a property available in SP.Web (SP.js) object to retrieve the collection of content types from parent site and the current site.

The below link redirects you to the property, which helps in retrieving the collection of available content types,
https://msdn.microsoft.com/en-us/library/office/jj245696.aspx
Property Name: SP.Web.availableContentTypes property (sp.js)
The below code supports the SharePoint Online and SharePoint 2013 plus
The code returns the Content type name and its id.

One thought on “JSOM: Get all content types from SharePoint web

  1. Jeff L. Reply

    Thank you so much for this! I was stuggling with a sub-site trying to retrieve the content types and it was not pulling back the parent site content types. I was using get_contentTypes() rather than get_availableContentTypes().

    So in summary:
    get_contentTypes() – Only retrieves that sites content types
    get_availableContentTypes() – Retrieves current and parent sites’ content types

Leave a Reply

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