Forum Discussion

warrenbarton's avatar
warrenbarton
Copper Contributor
Jan 14, 2021
Solved

SharePoint Online JavaScript creates folder instead of document set

Hello! We have a SharePoint Online system with 4 custom new forms created with Html/JavaScript. These forms used to create document sets and worked very well for a year (the forms are for different d...
  • ganeshsanap's avatar
    Jan 18, 2021

    warrenbarton 

     

    This issue seems to be due to some changes in SharePoint Online after 12th January.

     

    To fix this issue: use the list.contentTypeID instead of web.ContentTypeID.

     

    Change your code like this:

     

     

     

    var docSetContentTypeID = '<The list DocumentSet contentTypeID>';
    currentDate = new Date().getFullYear();
    ctx.load(list);
    folderUrl = "dummy" + currentDate;
    var folder = web.getFolderByServerRelativeUrl(folderUrl);
    ctx.load(folder); 
    //use list.get_contentTypes()
    var docsetContentType = list.get_contentTypes().getById(docSetContentTypeID);
    ctx.load(docsetContentType);

     

     

     

    Check more information in below related threads:

    1. SharePoint Online JavaScript creates folder instead of document set 
    2. Document Set created programmatically not working anymore since 12 Jan 2021 

    Please click Mark as Best Response if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Resources