Jan 14 2021 03:27 AM
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.
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.
Thank you very much!
Jan 15 2021 06:12 AM
We are also getting affected by this patch update from Microsoft. looking for a solution from Microsoft.
Jan 17 2021 11:19 PM
Jan 18 2021 12:23 AM
Solution
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:
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.
Jan 18 2021 12:38 AM
Jan 18 2021 12:23 AM
Solution
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:
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.