DocumentSet.Create DocumentSet.Create DocumentSet.Create Method

Definition

Overloads

Create(SPFolder, String, SPContentTypeId) Create(SPFolder, String, SPContentTypeId) Create(SPFolder, String, SPContentTypeId)

Creates a new Microsoft.Ofice.DocumentManagement.DocumentSets.DocumentSet object.

Create(SPFolder, String, SPContentTypeId, Hashtable) Create(SPFolder, String, SPContentTypeId, Hashtable) Create(SPFolder, String, SPContentTypeId, Hashtable)

Creates a new DocumentSet object.

Create(SPFolder, String, SPContentTypeId, Hashtable, Boolean) Create(SPFolder, String, SPContentTypeId, Hashtable, Boolean) Create(SPFolder, String, SPContentTypeId, Hashtable, Boolean)

Creates a new DocumentSet object.

Create(SPFolder, String, SPContentTypeId, Hashtable, Boolean, SPUser) Create(SPFolder, String, SPContentTypeId, Hashtable, Boolean, SPUser) Create(SPFolder, String, SPContentTypeId, Hashtable, Boolean, SPUser)

Creates a new DocumentSet object.

Create(SPFolder, String, SPContentTypeId) Create(SPFolder, String, SPContentTypeId) Create(SPFolder, String, SPContentTypeId)

Creates a new Microsoft.Ofice.DocumentManagement.DocumentSets.DocumentSet object.

public:
 static System::String ^ Create(Microsoft::SharePoint::SPFolder ^ parentFolder, System::String ^ name, Microsoft::SharePoint::SPContentTypeId ctid);
[Microsoft.SharePoint.Client.ClientCallableExceptionConstraint(Condition="Cannot create document set because another file or folder with this name already exists.", ErrorType=typeof(System.InvalidOperationException), FixedId="InvalidOperationException")]
[Microsoft.SharePoint.Client.ClientCallableMethod(ClientLibraryTargets=Microsoft.SharePoint.Client.ClientLibraryTargets.NonRESTful)]
public static string Create (Microsoft.SharePoint.SPFolder parentFolder, string name, Microsoft.SharePoint.SPContentTypeId ctid);
Public Shared Function Create (parentFolder As SPFolder, name As String, ctid As SPContentTypeId) As String
Parameters
parentFolder
SPFolder SPFolder SPFolder

The folder in which to create the new DocumentSet object.

name
String String String

The name of the new DocumentSet object.

ctid
SPContentTypeId SPContentTypeId SPContentTypeId

The ID of the content type to be used for the new document set to be created. The ID must be a content type that inherits from the base DocumentSet content type.

Returns

The URL to the new DocumentSet object.

Exceptions

The parent folder parameter is a null reference (Nothing in Visual Basic).

Examples

using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SharePoint.Client; using Microsoft.SharePoint.Client.DocumentSet; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { ClientContext ctx = new ClientContext("http://localhost/"); Web targetWeb = ctx.Web; List targetList = targetWeb.Lists.GetByTitle("docsets"); ContentTypeCollection listContentTypes = targetList.ContentTypes; ctx.Load(listContentTypes, types => types.Include (type => type.Id, type => type.Name, type => type.Parent)); var result = ctx.LoadQuery(listContentTypes.Where (c => c.Name == "Document Set")); ctx.ExecuteQuery(); ContentType docsetCT = result.First(); ContentTypeId ctid = docsetCT.Id; DocumentSet.Create(ctx, targetList.RootFolder, "wsDocset", ctid); ctx.ExecuteQuery(); } } }

Remarks

This version of the Create method always provisions default contents for the content type, if any.

This method tries to assign any values found in the hash table to the appropriate fields in the new DocumentSet object. The values are copied to the new object only if they are valid fields present in the content type. Values for unknown fields are ignored.

Create(SPFolder, String, SPContentTypeId, Hashtable) Create(SPFolder, String, SPContentTypeId, Hashtable) Create(SPFolder, String, SPContentTypeId, Hashtable)

Creates a new DocumentSet object.

public:
 static Microsoft::Office::DocumentManagement::DocumentSets::DocumentSet ^ Create(Microsoft::SharePoint::SPFolder ^ parentFolder, System::String ^ name, Microsoft::SharePoint::SPContentTypeId ctid, System::Collections::Hashtable ^ properties);
public static Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet Create (Microsoft.SharePoint.SPFolder parentFolder, string name, Microsoft.SharePoint.SPContentTypeId ctid, System.Collections.Hashtable properties);
Public Shared Function Create (parentFolder As SPFolder, name As String, ctid As SPContentTypeId, properties As Hashtable) As DocumentSet
Parameters
parentFolder
SPFolder SPFolder SPFolder

The folder that contains the DocumentSet object.

name
String String String

The name of the new DocumentSet object.

ctid
SPContentTypeId SPContentTypeId SPContentTypeId

The content type identifier on which to base the new DocumentSet object.

properties
Hashtable Hashtable Hashtable

The properties of the new DocumentSet object.

Returns

Examples

<p>The code example creates a new document set in the root folder of a specified list. The example assumes that the Description and Project Client columns used in the properties hash table are already defined at the site level.</p>
<p>Namespace references:</p>
<ul><li>
      <xref data-throw-if-not-resolved="true" uid="Microsoft.Office.DocumentManagement.DocumentSets"></xref>
    </li><li>
      <xref data-throw-if-not-resolved="true" uid="Microsoft.SharePoint"></xref>
    </li><li>
      <xref data-throw-if-not-resolved="true" uid="System.Web"></xref>
    </li></ul>
<pre><code>            //Get the folder into which to insert the document set.
        SPWeb web = new SPSite("&lt;span class="placeholder"&gt;URL_of_Site_for_DocSet&lt;/span&gt;").OpenWeb();
        SPList list = web.Lists["&lt;span class="placeholder"&gt;List_Name_for_DocSet&lt;/span&gt;"];
        SPFolder folderToInsertIn = list.RootFolder;

        //Get the content type ID for the specified document set content type.
        SPContentTypeId dsCtId = new SPContentTypeId();
        dsCtId = list.ContentTypes["&lt;span class="placeholder"&gt;DocumentSet_ContentType_Name&lt;/span&gt;"].Id;

        // Create the Document Set Properties HashTable
        Hashtable properties = new Hashtable();
        properties.Add("Description", "Project Description");
        properties.Add("Project Client", "AdventureWorks");

        //Create the new Document Set object.
        DocumentSet.Create(folderToInsertIn, "&lt;span class="placeholder"&gt;New_DocumentSet_Name&lt;/span&gt;", dsCtId, properties, true);

Remarks

This version of the Create method always provisions default contents for the content type, if default contents exist.

This method tries to assign any values found in the hash table to the appropriate fields in the new DocumentSet object. The values are copied to the new object only if they are valid fields present in the content type. Values for unknown fields are ignored.

Create(SPFolder, String, SPContentTypeId, Hashtable, Boolean) Create(SPFolder, String, SPContentTypeId, Hashtable, Boolean) Create(SPFolder, String, SPContentTypeId, Hashtable, Boolean)

Creates a new DocumentSet object.

public:
 static Microsoft::Office::DocumentManagement::DocumentSets::DocumentSet ^ Create(Microsoft::SharePoint::SPFolder ^ parentFolder, System::String ^ name, Microsoft::SharePoint::SPContentTypeId ctid, System::Collections::Hashtable ^ properties, bool bProvisionDefaultContent);
public static Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet Create (Microsoft.SharePoint.SPFolder parentFolder, string name, Microsoft.SharePoint.SPContentTypeId ctid, System.Collections.Hashtable properties, bool bProvisionDefaultContent);
Public Shared Function Create (parentFolder As SPFolder, name As String, ctid As SPContentTypeId, properties As Hashtable, bProvisionDefaultContent As Boolean) As DocumentSet
Parameters
parentFolder
SPFolder SPFolder SPFolder

The folder that contains the DocumentSet object.

name
String String String

The name of the new DocumentSet object.

ctid
SPContentTypeId SPContentTypeId SPContentTypeId

The content type identifier on which to base the new DocumentSet object.

properties
Hashtable Hashtable Hashtable

The properties of the new DocumentSet object.

bProvisionDefaultContent
Boolean Boolean Boolean

true to provision the default content for the DocumentSet object; otherwise, false.

Returns

Remarks

This version of the Create method always provisions default contents for the content type , if there are any. It tries to assign any values found in the hash table to the appropriate fields in the new DocumentSet object. The values are copied to the new object only if they are valid fields in the content type. Values for unknown fields are ignored.

Create(SPFolder, String, SPContentTypeId, Hashtable, Boolean, SPUser) Create(SPFolder, String, SPContentTypeId, Hashtable, Boolean, SPUser) Create(SPFolder, String, SPContentTypeId, Hashtable, Boolean, SPUser)

Creates a new DocumentSet object.

public:
 static Microsoft::Office::DocumentManagement::DocumentSets::DocumentSet ^ Create(Microsoft::SharePoint::SPFolder ^ parentFolder, System::String ^ name, Microsoft::SharePoint::SPContentTypeId ctid, System::Collections::Hashtable ^ properties, bool bProvisionDefaultContent, Microsoft::SharePoint::SPUser ^ user);
public static Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet Create (Microsoft.SharePoint.SPFolder parentFolder, string name, Microsoft.SharePoint.SPContentTypeId ctid, System.Collections.Hashtable properties, bool bProvisionDefaultContent, Microsoft.SharePoint.SPUser user);
Public Shared Function Create (parentFolder As SPFolder, name As String, ctid As SPContentTypeId, properties As Hashtable, bProvisionDefaultContent As Boolean, user As SPUser) As DocumentSet
Parameters
parentFolder
SPFolder SPFolder SPFolder

The SPFolder object to which the DocumentSet object is to be imported

name
String String String

The name of the new DocumentSet object

ctid
SPContentTypeId SPContentTypeId SPContentTypeId

The ID of the content type to use for creating the new DocumentSet object

properties
Hashtable Hashtable Hashtable

The collection of property values to be assigned to the new fields of the DocumentSet object

bProvisionDefaultContent
Boolean Boolean Boolean

true if default documents will be provisioned for the new DocumentSet object

user
SPUser SPUser SPUser

The user to set as the Author of the new DocumentSet

Returns

Remarks

This method will try to assign any values found in the hashtable to the appropiate fields in the new DocumentSet object, the values will be copied to the new object only if they are valid fields present in the Content Type, values for unknown fields will be ignored.

The ctid parameter must be a content type that inherits from the base DocumentSet content type

Applies to