locked
Set Default Content Type in csom RRS feed

  • Question

  • I need someone to review my code, I am trying to set the default content type for my list, it does not seem to work after all, am I doing something wrong, isn't the code submitted to the server?

    var context = SP.ClientContext.get_current();
    var folder = context.get_web().get_lists().getByTitle("announcements").get_rootFolder();
    context.load(folder, 'ContentTypeOrder');
    context.executeQueryAsync(function() {
      folder.set_uniqueContentTypeOrder(folder.get_contentTypeOrder()); 
      folder.update();
      context.executeQueryAsync();
    });

    any help appreciated.

    Wednesday, July 1, 2015 9:24 PM

Answers

  • You're missing the reverse method in order to change the order for the content types, your line of code should be:

    folder.set_uniqueContentTypeOrder(folder.get_contentTypeOrder().reverse()); 

    Let's know if that works.


    Mohamed Derhalli

    SharePoint Consultant

    Blog: SharePoint Thoughts    Twitter:    LinkedIn:   

    • Marked as answer by T_Richie Tuesday, July 21, 2015 5:03 PM
    • Unmarked as answer by T_Richie Tuesday, July 21, 2015 5:03 PM
    • Marked as answer by T_Richie Tuesday, July 21, 2015 5:03 PM
    Thursday, July 2, 2015 1:29 AM