DocumentSetTemplate DocumentSetTemplate DocumentSetTemplate Class


Represents the template on which DocumentSet objects are based.

public ref class DocumentSetTemplate
public class DocumentSetTemplate
Public Class DocumentSetTemplate


<pre><code>using System;

using Microsoft.SharePoint; using Microsoft.Office.DocumentManagement.DocumentSets;

namespace SyncAllDocsetTemplates { class Program { static void Main(string[] args) { //Sets a field as shared and adds an allowed content type //to all document set content types, the field that is now //shared will be displayed on the welcome page //and all of the default documents will be made to have the //newly allowed content type using (SPSite site = new SPSite("http://localhost")) //get the site { using (SPWeb web = site.RootWeb) //get the web { SPField field = web.Fields["ExistingField"];//get the new field SPContentType contentType = web.ContentTypes["ExistingCT"];//get the new content type foreach (SPContentType ct in web.ContentTypes)//iterate through all content types { if (DocumentSetTemplate.Id.IsParentOf(ct.Id) || ct.Id == DocumentSetTemplate.Id)//only take action if it's the base document set content type or one of its childs { //Get the document set template DocumentSetTemplate docsetTemplate = DocumentSetTemplate.GetDocumentSetTemplate(ct); //Add the new content type, make the field shared, and add it to the welcomepage docsetTemplate.AllowedContentTypes.Add(contentType.Id); docsetTemplate.SharedFields.Add(field); docsetTemplate.WelcomePageFields.Add(field); //Change the content type of all default documents to the new content type foreach (DefaultDocument defDoc in docsetTemplate.DefaultDocuments) { docsetTemplate.DefaultDocuments.ChangeContentTypeForDocument(defDoc.Name, contentType.Id); } //Finally, save the changes docsetTemplate.Update(false); } } } } } } }


There is one template for each document set content type and one template for every other content type that inherits from it. Templates describe properties of the document set content type. These properties include the content types allowed inside the document set, its default documents, its shared fields, the fields that are displayed in its welcome page, and the view to use for the welcome page.


AllowedContentTypes AllowedContentTypes AllowedContentTypes

Gets a collection of the content types allowed in DocumentSet objects that have this template.

DefaultDocuments DefaultDocuments DefaultDocuments

Gets the collection of DefaultDocument objects that are used for the DocumentSet objects that are associated with this template.

Id Id Id

Returns the parent SPContentTypeId object for document sets.

SharedFields SharedFields SharedFields

Gets the collections of fields that are synchronised between the DocumentSet object and its contents.

WelcomePageFields WelcomePageFields WelcomePageFields

Gets the collections of fields that are displayed on the welcome page of DocumentSet objects that use this template.

WelcomePageView WelcomePageView WelcomePageView

Gets or sets the view to use in displaying the contents of document sets on the welcome page of DocumentSet objects that use this template.


GetDocumentSetTemplate(SPContentType) GetDocumentSetTemplate(SPContentType) GetDocumentSetTemplate(SPContentType)

Gets the DocumentSetTemplate from a SPContentType object.

Update(Boolean) Update(Boolean) Update(Boolean)

Saves any changes made to the template.

Extension Methods

ToJson(Object) ToJson(Object) ToJson(Object)

Applies to