Document set
To create and manage multi-document work products consistently, we can use document sets. For this, we need to configure a new document set content type for each multi-document work product, which they typically create.
The document set content type is a folder-based content type, which organizes multiple related documents into a single view, where they can work on and managed as a single entity.
Include JS file given below before we execute the function.
sp.documentmanagement.js
Site Collection administrator is required to activate the document sets feature before you 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-->click Site collection features.
- Find document sets in the list and click Activate.
- Call the reusable function.
- SP.SOD.executeFunc('sp.documentmanagement.js', 'SP.DocumentSet.DocumentSet', function() {
-
- createDocumentSet(_spPageContextInfo.webAbsoluteUrl,'TutorialDocuments','Tutorials',printInfo,logError);
-
- });
- shareimprove this answer
-
-
- function createDocumentSet(Url,listname,docSetName,success,error) {
- var context = new SP.ClientContext(Url);
- var web = context.get_web();
- var list = web.get_lists().getByTitle(listname);
- context.load(list);
-
- var parentFolder = list.get_rootFolder();
- context.load(parentFolder);
-
- var docSetContentTypeID = "0x0120D520";
- var docSetContentType = context.get_site().get_rootWeb().get_contentTypes().getById(docSetContentTypeID);
- context.load(docSetContentType);
-
- context.executeQueryAsync(function (){
- SP.DocumentSet.DocumentSet.create(context, parentFolder, docSetName, docSetContentType.get_id());
- context.executeQueryAsync(success,error);
- },
- error);
- }
Thanks for reading my blog. Please post your feedback, so that I can improve.