How to Create a document set using JSOM in SharePoint online/Office 365?

Hello SharePointers,

Here is the JSOM code to create a document set using JSOM.

 

docSetName = “RequirementDocset;
var context = new SP.ClientContext(_spPageContextInfo.webServerRelativeUrl);
var list = context.get_web().get_lists().getById(‘GUID of List’);

context.load(list);

var itemCreateInfo = new SP.ListItemCreationInformation();
itemCreateInfo.set_underlyingObjectType(SP.FileSystemObjectType.folder);
itemCreateInfo.set_leafName(docSetName);

var listitem

listitem= list.addItem(itemCreateInfo);
listitem.set_item(“ContentTypeId”, “GUID”);
listitem.set_item(‘Title’, docSetName);
listitem.set_item(‘DocumentSetDescription’, “This is Req set Document Set”);
listitem.set_item(‘ChartIdlookup’, itemid);

listitem.update();
context.load(listitem);
context.executeQueryAsync(
function() { console.log(“document-set created!”);} ,

Happy SharePointing Folks 🙂

Leave a Reply

Your email address will not be published.