Create A Document Set In SharePoint 2013 Using JSOM

Introduction

In this blog, I would like to explain how to create Document Set In Document Library, using JSOM. A Document Set is a group of related documents, which can be created in one step and then managed as a single entity.

Source Code

  1. $(document).ready(function() {  
  2.     createDocumentSet();  
  3.   
  4. });  
  5.   
  6. functioncreateDocumentSet() {  
  7.   
  8.     varclientContext = new SP.ClientContext.get_current();  
  9.     oWeb = clientContext.get_web();  
  10.     varoList = oWeb.get_lists().getByTitle("TestLibrary");  
  11.   
  12.     clientContext.load(oList);  
  13.   
  14.     varLibraryFolder = oList.get_rootFolder();  
  15.     clientContext.load(LibraryFolder);  
  16.   
  17.     vardocumentSetContentTypeID = "0x0120D520";  
  18.   
  19.     vardocumentSetContentType = clientContext.get_site().get_rootWeb().get_contentTypes().getById(documentSetContentTypeID);  
  20.   
  21.     clientContext.load(documentSetContentType);  
  22.   
  23.     clientContext.executeQueryAsync(QuerySuccess, QueryFailure);  
  24. }  
  25.   
  26. functionQuerySuccess() {  
  27.   
  28.     vardocumentSetName = "DocumentSetName";  
  29.     SP.DocumentSet.DocumentSet.create(clientContext, oLibraryFolder, documentSetName, documentSetContentType.get_id());  
  30.     clientContext.executeQueryAsync(Success, Failure);  
  31. }  
  32.   
  33. functionQueryFailure() {  
  34.     console.log('Request failed - ' + args.get_message());  
  35. }  
  36.   
  37. function Success() {  
  38.     console.log('DocumentSet Created Successfully.');  
  39. }  
  40.   
  41. function Failure(sender, args) {  
  42.     console.log('Request failed - ' + args.get_message());  
  43. }  
Activate Document Set Feature

We need to activate it before you can create or configure new Document Set content types. 
  • Go to the top-level site in the site collection for which you want to enable Document Sets.
  • Site Actions menu--> click Site Settings.
  • Site Collection Administration- Site collection features.
  • Find Document Sets in the list and click Activate.

Add Document Set as a Content Type to your Document Library,

  • Go to Document Settings and change the Advanced Settings to Allow management of content types.

    Introduction In this article I would like to explain how to create Document Set In Document Library Using JSOM. A Document Set is a group of related documents that can be created in one step and then managed as a single entity. Source Code: $(document).ready(function() { createDocumentSet(); }); functioncreateDocumentSet() { varclientContext = new SP.ClientContext.get_current(); oWeb = clientContext.get_web(); varoList = oWeb.get_lists().getByTitle("TestLibrary"); clientContext.load(oList); varLibraryFolder = oList.get_rootFolder(); clientContext.load(LibraryFolder); vardocumentSetContentTypeID = "0x0120D520"; vardocumentSetContentType = clientContext.get_site().get_rootWeb().get_contentTypes().getById(documentSetContentTypeID); clientContext.load(documentSetContentType); clientContext.executeQueryAsync(QuerySuccess, QueryFailure); } functionQuerySuccess() { vardocumentSetName = "DocumentSetName"; SP.DocumentSet.DocumentSet.create(clientContext, oLibraryFolder, documentSetName, documentSetContentType.get_id()); clientContext.executeQueryAsync(Success, Failure); } functionQueryFailure() { console.log('Request failed - ' + args.get_message()); } function Success() { console.log('DocumentSet Created Successfully.'); } function Failure(sender, args) { console.log('Request failed - ' + args.get_message()); } Activate Document Set Feature We need to activate it before you can create or configure new Document Set content types. Go to the top-level site in the site collection for which you want to enable Document Sets. Site Actions menu-- />click Site Settings. Site Collection Administration? Site collection features. Find Document Sets in the list, and then click Activate. Add Document Set as a Content Type to your Document Library Go to Document Settings and change the Advanced Settings to: Allow management of content types Then Goto the Settings?add from existing site content types and find the Document Set content type. Select Document Set and click Add: Go to your Document library and select New Document -> Document Set from the drop-down list, Here we will see how to create a Document Set programmatically using csom,

  • Go to the Settings- add from existing site content types and find the Document Set content type. Select Document Set and click Add.

    Introduction In this article I would like to explain how to create Document Set In Document Library Using JSOM. A Document Set is a group of related documents that can be created in one step and then managed as a single entity. Source Code: $(document).ready(function() { createDocumentSet(); }); functioncreateDocumentSet() { varclientContext = new SP.ClientContext.get_current(); oWeb = clientContext.get_web(); varoList = oWeb.get_lists().getByTitle("TestLibrary"); clientContext.load(oList); varLibraryFolder = oList.get_rootFolder(); clientContext.load(LibraryFolder); vardocumentSetContentTypeID = "0x0120D520"; vardocumentSetContentType = clientContext.get_site().get_rootWeb().get_contentTypes().getById(documentSetContentTypeID); clientContext.load(documentSetContentType); clientContext.executeQueryAsync(QuerySuccess, QueryFailure); } functionQuerySuccess() { vardocumentSetName = "DocumentSetName"; SP.DocumentSet.DocumentSet.create(clientContext, oLibraryFolder, documentSetName, documentSetContentType.get_id()); clientContext.executeQueryAsync(Success, Failure); } functionQueryFailure() { console.log('Request failed - ' + args.get_message()); } function Success() { console.log('DocumentSet Created Successfully.'); } function Failure(sender, args) { console.log('Request failed - ' + args.get_message()); } Activate Document Set Feature We need to activate it before you can create or configure new Document Set content types. Go to the top-level site in the site collection for which you want to enable Document Sets. Site Actions menu-- />click Site Settings. Site Collection Administration? Site collection features. Find Document Sets in the list, and then click Activate. Add Document Set as a Content Type to your Document Library Go to Document Settings and change the Advanced Settings to: Allow management of content types Then Goto the Settings?add from existing site content types and find the Document Set content type. Select Document Set and click Add: Go to your Document library and select New Document -> Document Set from the drop-down list, Here we will see how to create a Document Set programmatically using csom,
  • Go to your Document library and select New Document -> Document Set from the drop-down list,

    Introduction In this article I would like to explain how to create Document Set In Document Library Using JSOM. A Document Set is a group of related documents that can be created in one step and then managed as a single entity. Source Code: $(document).ready(function() { createDocumentSet(); }); functioncreateDocumentSet() { varclientContext = new SP.ClientContext.get_current(); oWeb = clientContext.get_web(); varoList = oWeb.get_lists().getByTitle("TestLibrary"); clientContext.load(oList); varLibraryFolder = oList.get_rootFolder(); clientContext.load(LibraryFolder); vardocumentSetContentTypeID = "0x0120D520"; vardocumentSetContentType = clientContext.get_site().get_rootWeb().get_contentTypes().getById(documentSetContentTypeID); clientContext.load(documentSetContentType); clientContext.executeQueryAsync(QuerySuccess, QueryFailure); } functionQuerySuccess() { vardocumentSetName = "DocumentSetName"; SP.DocumentSet.DocumentSet.create(clientContext, oLibraryFolder, documentSetName, documentSetContentType.get_id()); clientContext.executeQueryAsync(Success, Failure); } functionQueryFailure() { console.log('Request failed - ' + args.get_message()); } function Success() { console.log('DocumentSet Created Successfully.'); } function Failure(sender, args) { console.log('Request failed - ' + args.get_message()); } Activate Document Set Feature We need to activate it before you can create or configure new Document Set content types. Go to the top-level site in the site collection for which you want to enable Document Sets. Site Actions menu-- />click Site Settings. Site Collection Administration? Site collection features. Find Document Sets in the list, and then click Activate. Add Document Set as a Content Type to your Document Library Go to Document Settings and change the Advanced Settings to: Allow management of content types Then Goto the Settings?add from existing site content types and find the Document Set content type. Select Document Set and click Add: Go to your Document library and select New Document -> Document Set from the drop-down list, Here we will see how to create a Document Set programmatically using csom,

Here, we will see how to create a Document Set programatically, using Jsom.