SharePoint Online JavaScript creates folder instead of document set

%3CLINGO-SUB%20id%3D%22lingo-sub-2060369%22%20slang%3D%22en-US%22%3ESharePoint%20Online%20JavaScript%20creates%20folder%20instead%20of%20document%20set%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2060369%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EHello!%20We%20have%20a%20SharePoint%20Online%20system%20with%204%20custom%20new%20forms%20created%20with%20Html%2FJavaScript.%20These%20forms%20used%20to%20create%20document%20sets%20and%20worked%20very%20well%20for%20a%20year%20(the%20forms%20are%20for%20different%20document%20libraries%20on%20different%20subsites).%20Starting%20yesterday%2C%20they%20suddenly%20creating%20folders%20instead%20of%20document%20sets.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22vt_stack.JPG%22%20style%3D%22width%3A%20367px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F246364i04AA8570B3661739%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22vt_stack.JPG%22%20alt%3D%22vt_stack.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EInteresting%2C%20but%20the%20folders%20have%20the%20correct%20content%20type%2C%20not%20Folder%20content%20type.%20We%20checked%20and%20the%20content%20type%20id's%20havent%20changed.%20Here%20is%20the%20JS%20code%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-javascript%22%3E%3CCODE%3Efunction%20createDocset()%20%7B%0Avar%20ctx%20%3D%20new%20SP.ClientContext(_spPageContextInfo.webServerRelativeUrl)%3B%0Avar%20web%20%3D%20ctx.get_web()%3B%0Avar%20list%20%3D%20web.get_lists().getByTitle('dummy')%3B%0ASP.SOD.executeFunc('sp.js'%2C%20'SP.ClientContext')%3B%20%0AnewDocSetName%20%3D%20'dummy'%3B%0Avar%20docSetContentTypeID%20%3D%20'0x0120D52000A5EFC11713588E41B8E1058A74F53AF2'%3B%0AcurrentDate%20%3D%20new%20Date().getFullYear()%3B%0Actx.load(list)%3B%0AfolderUrl%20%3D%20%22dummy%22%20%2B%20currentDate%3B%0Avar%20folder%20%3D%20web.getFolderByServerRelativeUrl(folderUrl)%3B%0Actx.load(folder)%3B%20%20%20%0Avar%20docsetContentType%20%3D%20web.get_contentTypes().getById(docSetContentTypeID)%3B%0Actx.load(docsetContentType)%3B%0Actx.executeQueryAsync(function%20()%20%7B%0A%20%20%20%20console.log(%22Content-type%3A%20%22%20%2B%20docsetContentType)%3B%0AisCreated%20%3D%20SP.DocumentSet.DocumentSet.create(ctx%2C%20folder%2C%20newDocSetName%2C%20docsetContentType.get_id())%3B%0Aconsole.log(%22Created%3A%20%22%2C%20isCreated)%3B%0Actx.executeQueryAsync(SuccessHandler('Document%20Set%20creation%20successful')%2C%20FailureHandler(%22Document%20Set%20creation%20failed%22))%3B%0A%7D%2C%20FailureHandler(%22Folder%20loading%20failed%22))%3B%0Actx.add_requestSucceeded(function%20()%20%7B%0A%7D)%3B%0Actx.add_requestFailed(function%20(sender%2C%20args)%20%7B%0Aalert('Request%20failed%3A%20'%20%2B%20args.get_message())%3B%0A%7D)%3B%0A%2F%2F%20Failure%20Message%20Handler%0Afunction%20FailureHandler(message)%20%7B%0A%20%20%20%20return%20function%20(sender%2C%20args)%20%7B%0A%20%20%20%20%20%20%20%20alert(message%20%2B%20%22%3A%20%22%20%2B%20args.get_message())%3B%0A%20%20%20%20%7D%0A%7D%0A%2F%2F%20Success%20Message%20Handler%0Afunction%20SuccessHandler(message)%20%7B%0A%20%20%20%20return%20function%20()%20%7B%0A%20%20%20%20%20%20%20%20setDocset()%3B%0A%20%20%20%20%7D%0A%7D%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EThere%20are%202%20custom%20document%20set%20content%20types%20in%20this%20library.%20The%20forms%20using%20their%20content%20type%20id's.%20The%20id's%20havent%20changed.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22vt-docset-2.JPG%22%20style%3D%22width%3A%20204px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F246365iE9F6539581B89B74%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22vt-docset-2.JPG%22%20alt%3D%22vt-docset-2.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22vt-docset-1.JPG%22%20style%3D%22width%3A%20130px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F246366iA2A66EBD52E66D5D%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22vt-docset-1.JPG%22%20alt%3D%22vt-docset-1.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EThank%20you%20very%20much!%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2060369%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Visitor

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

 

vt_stack.JPG

 

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();
ctx.load(list);
folderUrl = "dummy" + currentDate;
var folder = web.getFolderByServerRelativeUrl(folderUrl);
ctx.load(folder);   
var docsetContentType = web.get_contentTypes().getById(docSetContentTypeID);
ctx.load(docsetContentType);
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 () {
        setDocset();
    }
}}

 

 

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

 

vt-docset-2.JPG

 

vt-docset-1.JPG

 

Thank you very much!

1 Reply

We are also getting affected by this patch update from Microsoft. looking for a solution from Microsoft.