Skip to content

Instantly share code, notes, and snippets.

@phillipharding
Last active October 6, 2016 18:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phillipharding/e42364c7792552b09134 to your computer and use it in GitHub Desktop.
Save phillipharding/e42364c7792552b09134 to your computer and use it in GitHub Desktop.
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