Export (0) Print
Expand All
Expand Minimize

Creating and Customizing Document Sets in SharePoint Server 2010

SharePoint 2010

SharePoint Visual How To

Summary:  Learn how to create SharePoint Server 2010 document sets by using Visual Studio 2010 instead of by using the browser-based user interface.

Last modified: September 12, 2012

Applies to: SharePoint Foundation 2010 | SharePoint Server 2010 | Visual Studio | Visual Studio 2008 | Visual Studio 2010

Provided by:  Andrew Connell, Critical Path Training, LLC (SharePoint MVP)

Overview

Document sets, introduced in Microsoft SharePoint Server 2010, enable users to create a composite item that consists of properties and child documents. This enables customers to associate multiple documents with a single work item and wrap them into a single version or workflow. The SharePoint browser-based user interface (UI) makes it easy to create document sets. However, developers may want to create document sets by using Microsoft Visual Studio 2010 and package them in portable and reusable solution packages (.wsp files). This Visual How To demonstrates how to create a custom document set by using the SharePoint development tools in Microsoft Visual Studio 2010.

Code It

Creating custom Microsoft SharePoint 2010 document sets by using the browser-based UI is fairly intuitive. However, this work can become more complicated when you are creating them by using SharePoint Features. Document Sets can be created by using new additions to the SharePoint object model, but SharePoint Features provide the most reusability and portability when they are deployed by using SharePoint solution packages.

Creating Supporting Content Types

There are a few aspects about document sets that are important to understand. A document set can contain fields just as traditional content types can. Document Sets also contain content types that define the child items that reside within the document set. When the document set and child content types share the same fields, these fields can be flagged as shared fields. When a field is flagged as a shared field, it is updated in all child content types when the parent field in the document set is updated. Defining content types within a Feature for use within a document set is made easier by using the SharePoint development tools in Visual Studio 2010. The following markup creates a content type and provisions a default template.

<Module Name="DefaultDocuments" Url="_cts/Timesheet">
  <File Path="DefaultDocuments\WingtipTimesheet.xsn"
        Url="WingtipTimesheet.xsn" />
</Module>
<!-- Parent ContentType: Form (0x010101) -->
<ContentType ID="0x01010100c5b7e126a89c4f13b0fa8c37dece6876"
             Name="Timesheet"
             Description="Contractor timesheet."
             Group="MSDN"
             Version="0">
  <FieldRefs>
    <!-- Invoice Number -->
    <FieldRef ID="{83729202-DCA7-4BF8-A75B-56DDDE53189C}" Required="TRUE" />
  </FieldRefs>
  <DocumentTemplate TargetName="_cts/Timesheet/WingtipTimesheet.xsn" />
</ContentType>

Creating the Custom Document Set Welcome Page

Document sets appear in document libraries as single list items with a specific icon. When the user selects a document set, the document set's welcome page appears. This Web Parts page is used to show the document set's properties and all the contents in the set. As with any Web Parts page, this page is customizable. To customize it, create a custom file named DocSetHomePage.aspx, and then copy it to the top level (root) of the content type folder when it is provisioned into SharePoint. The root folder is usually _cts/content type name, but is defined in the content type, as shown in the following markup.

<ContentType ID="0x0120D5200095c2ea9e2d604fcabe3e059ea83fbcea"
             Name="Invoice Document Set"
             Description=""
             Group="MSDN"
             Version="0"
             ProgId="SharePoint.DocumentSet">
  <Folder TargetName="_cts/Invoice Document Set" />
</ContentType>

Specifying Shared Fields, Allowed Content Types, Welcome Page Fields, and Default Documents

The definition of a document set within a Feature can contain additional settings. These are all declared by using the <XmlDocuments> section in the content type definition. Each of these sections uses a specific XML namespace. For readability, the following markup has been trimmed from the code sample that is associated with this Visual How To.

<ContentType>
  <XmlDocuments>
    <!-- List of all fields [site columns] shared between all content types and the document set. -->
    <XmlDocument NamespaceURI="http://schemas.microsoft.com/office/documentsets/sharedfields">
    <sf:SharedFields 
    xmlns:sf="http://schemas.microsoft.com/office/documentsets/sharedfields" LastModified="1/1/2010 08:00:00 AM">
      <SharedField id="83729202-DCA7-4BF8-A75B-56DDDE53189C" />      
    </sf:SharedFields>
    </XmlDocument>
    <!-- List of all content types that are allowed in the document set. -->
    <XmlDocument NamespaceURI="http://schemas.microsoft.com/office/documentsets/allowedcontenttypes">
    <act:AllowedContentTypes 
    xmlns:act=
    "http://schemas.microsoft.com/office/documentsets/allowedcontenttypes" 
    LastModified="1/1/2010 08:00:00 AM">
      <AllowedContentType id="0x01010100c5b7e126a89c4f13b0fa8c37dece6876" />
    </act:AllowedContentTypes>
    </XmlDocument>
    <!-- List of all fields [site columns] that should appear on welcome page. -->
    <XmlDocument 
    NamespaceURI=
    "http://schemas.microsoft.com/office/documentsets/welcomepagefields">
    <wpFields:WelcomePageFields 
    xmlns:wpFields=
    "http://schemas.microsoft.com/office/documentsets/welcomepagefields" 
    LastModified="1/1/2010 08:00:00 AM">
      <WelcomePageField id="83729202-DCA7-4BF8-A75B-56DDDE53189C" />      
    </wpFields:WelcomePageFields>
    </XmlDocument>
    <!-- List of all default documents associated with the content types. -->
    <XmlDocument 
    NamespaceURI=
    "http://schemas.microsoft.com/office/documentsets/defaultdocuments">
    <dd:DefaultDocuments 
    xmlns:dd=
    "http://schemas.microsoft.com/office/documentsets/defaultdocuments" 
    AddSetName="TRUE" LastModified="1/1/2010 08:00:00 AM">
      <DefaultDocument name="WingtipTimesheet.xsn" 
      idContentType="0x01010100c5b7e126a89c4f13b0fa8c37dece6876" />
    </dd:DefaultDocuments>
    </XmlDocument>
  </XmlDocuments>
</ContentType>

Read It

Document sets in SharePoint Server 2010 enable users to incorporate real-world processes. With document sets, users can compile multiple work items into a single work product. Although each work item can have its own version, workflow, and metadata, the entire document set can have a single version, workflow, metadata, and permissions applied to it. This gives users the most flexibility to incorporate their day-to-day work into SharePoint, enabling SharePoint to provide the most value and productivity for users.

See It

Watch the video

Watch video

Length: 17:25

Click to grab code

Grab the Code (Critical Path Training)

Explore It

About the Author

MVP ContributorMVP Andrew Connell is an author, instructor, and co-founder of Critical Path Training, a SharePoint education-focused company. Andrew is a six-time recipient of Microsoft’s Most Valuable Professional (MVP) award (2005-2010) for Microsoft Content Management Server (MCMS) and Microsoft SharePoint Server. He authored and contributed to numerous MCMS and SharePoint books over the years including his book Professional SharePoint 2007 Web Content Management Development by WROX. Andrew speaks about SharePoint development and WCM at conferences such as Tech-Ed, SharePoint Connections, VSLive, SharePoint Best Practice Conference, SharePoint Evolutions Conference, Office Developer Conference, and Microsoft SharePoint Conference in the United States, Australia, England, and Spain. Andrew blogs at Andrew Connell Blog and on Twitter @andrewconnell.

Show:
© 2014 Microsoft