Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create Document Set using JSOM
var clientContext = null;
function createTestDocumentSet() {
if(clientContext === null) {
return false;
}
var item = null;
var oList = clientContext.get_web().get_lists().getByTitle('Library Name');
clientContext.load(oList);
var itemCreateInfo = new SP.ListItemCreationInformation();
itemCreateInfo.set_underlyingObjectType(SP.FileSystemObjectType.folder);
itemCreateInfo.set_leafName('Documentset Name');
item = oList.addItem(itemCreateInfo);
item.set_item("ContentTypeId", "0x0120D520");
item.set_item('Title', 'Documentset Name');
item.update();
clientContext.load(item);
clientContext.executeQueryAsync(
function() { console.log("document-set created!");} ,
function(sender,args) { console.log("Doh... " + args.get_message()); }
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment