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