How to programmatically (using CSOM/JSOM) uncheck the Visible checkbox for a content type: Content Type Order

so that the content type (Document Set above) is not anymore visible in FILES > New Document: New Item

In order to verify that the solution would work:

  1. Do the change
  2. Manually add the content type back and verify that it is shown again.
  • Have you tried setting Hidden property? msdn.microsoft.com/en-us/library/… – Slaven Semper Dec 3 '14 at 9:55
  • Yes. The Content Type gets hidden but the Visible checkbox seems to stop having any effect after setting the Hidden property; changing it seems to do a different thing but I don't know where can we do or undo the same in UI. – thomius Dec 3 '14 at 10:03
  • +1 As always a good question :) – Vadim Gremyachev Dec 3 '14 at 13:04

You need to set uniqueContentTypeOrder on the root folder of the list. Check SP.Folder.uniqueContentTypeOrder property here at msdn. Even though you need to do it in JSOM or CSOM, I will share a server object model code which may help you in resolving this issue:

using (SPSite site = new SPSite("http://aissp2013/sites/t1"))
    SPWeb web = site.RootWeb;
    SPList list = web.Lists["Hardware And Sanitary Products"];
    SPFolder folder = list.RootFolder;
    IList<SPContentType> uniqueContentTypeOrder = new List<SPContentType>();
    SPContentTypeCollection listContentTypes = list.ContentTypes;
    foreach (SPContentType ct in listContentTypes)
        if (ct.Name == "SanitaryItems")
        else if (ct.Name == "HardwareItems")

    if (uniqueContentTypeOrder.Count > 0)
        folder.UniqueContentTypeOrder = uniqueContentTypeOrder;

See here for more details.

  • 1
    This does not seem to hide any content types for me. It shows the content types listed in UniqueContentTypeOrder first, but lists all the rest of the content types afterwards. Is this not the case for you? – thomius Dec 3 '14 at 11:24
  • Add only required list content types in UniqueContentTypeOrder. – Nadeem Yousuf-AIS Dec 3 '14 at 11:27

The following example demonstrates how to accomplish it via CSOM:

/// <summary>
/// Hide the content type from List
/// </summary>
/// <param name="ctx"></param>
/// <param name="listTitle"></param>
/// <param name="ctName">The name of content type to hide</param>
private static void HideContentTypeFromList(ClientContext ctx, string listTitle,string ctName)
    var list = ctx.Web.Lists.GetByTitle(listTitle);

    //List Content Types 
    ctx.Load(list, l => l.ContentTypes, l => l.RootFolder.UniqueContentTypeOrder);
    var contentTypeOrder = (from ct in list.ContentTypes where ct.Name != ctName select ct.Id).ToList();
    list.RootFolder.UniqueContentTypeOrder = contentTypeOrder;


using (var ctx = new ClientContext(webUri))
     HideContentTypeFromList(ctx, listTitle, "Workflow Task (SharePoint 2013)");

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.