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 document libraries on different subsites). Starting yesterday, they suddenly creating folders instead of document sets.

doc library screenshot

Interesting, but the folders have the correct content type, not Folder content type. We checked and the content type id's havent changed. Here is the JS code:

function createDocset() {
var ctx = new SP.ClientContext(_spPageContextInfo.webServerRelativeUrl);
var web = ctx.get_web();
var list = web.get_lists().getByTitle('dummy');
SP.SOD.executeFunc('sp.js', 'SP.ClientContext'); 
newDocSetName = 'dummy';
var docSetContentTypeID = '0x0120D52000A5EFC11713588E41B8E1058A74F53AF2';
currentDate = new Date().getFullYear();
folderUrl = "dummy" + currentDate;
var folder = web.getFolderByServerRelativeUrl(folderUrl);
var docsetContentType = web.get_contentTypes().getById(docSetContentTypeID);
ctx.executeQueryAsync(function () {
    console.log("Content-type: " + docsetContentType);
isCreated = SP.DocumentSet.DocumentSet.create(ctx, folder, newDocSetName, docsetContentType.get_id());
console.log("Created: ", isCreated);
ctx.executeQueryAsync(SuccessHandler('Document Set creation successful'), FailureHandler("Document Set creation failed"));
}, FailureHandler("Folder loading failed"));
ctx.add_requestSucceeded(function () {
ctx.add_requestFailed(function (sender, args) {
alert('Request failed: ' + args.get_message());
// Failure Message Handler
function FailureHandler(message) {
    return function (sender, args) {
        alert(message + ": " + args.get_message());
// Success Message Handler
function SuccessHandler(message) {
    return function () {

Thank you very much!

EDIT: There are 2 custom document set content types in this library. The forms using their content type id's. The id's havent changed.

enter image description here

enter image description here

2 Answers 2


This could be the document set content type is removed from your library, please check if the document set content type is under the content types in library settings.

enter image description here

If it is there, you could try to use the ContentTypeID for document set: var docSetContentTypeID = '0x0120D520';


I reproduce your issue on my tenant. You could check my answer here: https://docs.microsoft.com/en-us/answers/questions/230335/document-set-created-programmtically-not-working-a.html?childToView=231298#answer-231298

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();
folderUrl = "dummy" + currentDate;
var folder = web.getFolderByServerRelativeUrl(folderUrl);
//use list.get_contentTypes()
var docsetContentType = list.get_contentTypes().getById(docSetContentTypeID);

To get the list contenttype id, go to library settings, click the document set content type. You could find it in the url.

enter image description here

Use this list contentTypeID would fix this:

enter image description here

  • Thank you Michael! I have updated the post with the information about the custom document set content types we are using. Addig the basic Document Set content type to the library and using its content type id in javascript gave the following error: Uncaught Error: Object reference not set to an instance of an object on server. The object is associated with method GetById. Jan 14, 2021 at 10:44
  • You could check my updated answer. Jan 15, 2021 at 2:52
  • Using the list content type id working fine. Its working too if you are using another document set create method (listItem.set_item("ContentTypeId", "***"). Thank you very much! Jan 15, 2021 at 8:07
  • you are welcome :) Jan 15, 2021 at 8:15

Our customer has the same problem. It appears since 4 p.m. 12th January 2021 German time. We did not change anything in the system since ~ 12 months. Here a excerpt of the source code:

var itemCreateInfo = new SP.ListItemCreationInformation();
var item = list.addItem(itemCreateInfo);

item.set_item('ContentTypeId', '0x....');

context.executeQueryAsync(function(sender, args) {

}, function(sender, args){      

It looks like this:

The document set is created correctly, it is accessable via docsethomepage.aspx In our opinion, the only difference is the icon and the link (to empty folder instead of docsethomepage.aspx) because the other columns are displayed correctly. So, we decided to open a ticket at the Microsoft Support. Additionally, as a temporary fix, we will use CSR (client side rendering) to fix the icon and the link.

  • Greetings! Our problem started at the same day. Could you help us with a link or email adress to reach out MS Support? Jan 14, 2021 at 14:52
  • @febe, use list documnetset contenttype id would fix this. You could check my answer Jan 15, 2021 at 2:53
  • 1
    @ warrenbarton: Go to admin.microsoft.com, you can open a ticket there. You need to be global (?) admin to have access to this site @MichaelHan_MSFT: It works, thank you for your help, Can you provide additional technical details about the issue? You seem to be a MS emplyee ;)
    – febe
    Jan 15, 2021 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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