Wednesday, May 25, 2011

What is Document Sets and How to create Document Sets in SharePoint 2010?

In this post we will discuss about What is Document Sets and How to create Document Sets in SharePoint 2010?

Also you can check out:

- Difference between site pages and application pages

- SharePoint 2010 List Tutorials

- Get 4 part assembly name of a custom web part in SharePoint 2010

We can create document libraries in SharePoint 2010 to store, maintain versions or to give unique permissions. But a single document does not represent a complete work product sometime. A work product may consist of multiple documents. So we used Folders can be used to group documents; however, folders cannot be versioned or be the target of an event receiver or workflow.

So it comes Document Set:
Document Set enables users to group multiple documents that support a single project or task, together into a single entity. All documents in a Document Set share the metadata and the entire set can also be versioned.

When you access a Document Set you get a web part page that displays the documents like they would be displayed in a document library view. There are also some other features available explained below which I have followed from the Inside SharePoint 2010 book.

Allowed Content Types: 
The types of content that are permitted within the document set.
Shared Fields: Common columns that exist on the document set and child content types. When the value is changed in the document set, SharePoint automatically updates the metadata on all documents in the document set with the new value.

Welcome Page:
SharePoint implements documents sets as a Web Part Page when users view them with a browser. The Welcome page displays specified fields from the document set’s content type, as well as the individual files that make up the document set.

Default Content: 
When users create a new instance of the document set, it can provision new content that is associated with one of the allowed content types automatically.
You can create programmatically like below:
public static void CreateDocumentSetContentType(string libraryUrl)
using (SPSite site = new SPSite(libraryUrl))
using (SPWeb web = site.OpenWeb())
//create the new document set contenttype
SPContentType newDocumentSet = web.ContentTypes.Add (new SPContentType(web.ContentTypes["Document Set"],web.ContentTypes,
//get a an instance of DocumentSetTemplate for the new document set
DocumentSetTemplate newDocumentSet = DocumentSetTemplate.GetDocumentSetTemplate(newDocumentSet );
//add allowable content types
//add a shareable property
newDocumentSet .Update();

No comments:

Post a Comment