How To Check Document Set In Document Library

Introduction

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

  1. $(document).ready(function() {    
  2.        getDocSet('Documents','Orders',success,logError);   
  3.              
  4.     });    
  5.   
  6.   
  7. function getDocSet(listTitle,docSetName, success,error) {  
  8.     var context = SP.ClientContext.get_current();  
  9.     var list = context.get_web().get_lists().getByTitle(listTitle);  
  10.     var items = list.getItems(createGetDocSetQuery(docSetName));  
  11.     context.load(items);  
  12.     context.executeQueryAsync(  
  13.       function() {  
  14.          var docSetItem = (items.get_count() > 0 ? items.getItemAtIndex(0) : null);  
  15.          success(docSetItem);  
  16.       },  
  17.       error   
  18.     );  
  19.   
  20.   
  21.     function createGetDocSetQuery(docSetName)  
  22.     {  
  23.         var query = new SP.CamlQuery();  
  24.         var viewXml =  
  25.         "<View>" +  
  26.         "<Query>" +  
  27.            "<Where>" +  
  28.                "<And>" +  
  29.                    "<Eq>" +  
  30.                       "<FieldRef Name=\"FSObjType\"/>" +  
  31.                       "<Value Type=\"Integer\">1</Value>" +  
  32.                    "</Eq>" +  
  33.                    "<Eq>" +  
  34.                       "<FieldRef Name=\"FileLeafRef\" />" +  
  35.                       "<Value Type=\"Text\">" + docSetName + "</Value>" +  
  36.                    "</Eq>" +  
  37.                "</And>" +  
  38.            "</Where>" +  
  39.         "</Query>" +  
  40.         "<RowLimit>1</RowLimit>" +  
  41.         "</View>";  
  42.         query.set_viewXml(viewXml);  
  43.         return query;  
  44.     }  
  45. }  
Activate Document Set Feature

We need to activate it before we 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.
  • Go to Site Actions menu-->click Site Settings.
  • Now, go to 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, go to 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.



That's it. I hope you liked this blog.

Ebook Download
View all
Learn
View all