Wednesday, August 3, 2011

Create Documentset programmatically in Sharepoint 2010

using (SPSite siteCollectionOuter = new SPSite(sSiteName))
   using (SPWeb site = siteCollectionOuter.OpenWeb())
site.AllowUnsafeUpdates = true;
SPList WorkingDocslist = site.Lists["Working Documents"];
SPFolder folderToInsertIn = WorkingDocslist.RootFolder;

//Get the content type ID for the specified document set content type.
SPContentTypeId dsCtId = new SPContentTypeId();

// Create the Document Set Properties HashTable
Hashtable properties = new Hashtable();
properties.Add("Project_x0020_Name", site.Title);
properties.Add("OPSCustomProjectID", sProjectID);
properties.Add("OPSTaskID", sTaskID);
properties.Add("DSType", sDocumentSetType);
properties.Add("DocumentSetDescription ");
properties.Add("DocumentSetVersion", "0.0");
properties.Add("CreatedBy", SPContext.Current.Web.CurrentUser.Name);
properties.Add("ModifiedBy", SPContext.Current.Web.CurrentUser.Name);

DocumentSet docset = null;
if (isTrue)
docset = DocumentSet.Create(folderToInsertIn, strDocSetName, dsCtId, properties, true);


No comments:

Post a Comment


Blog Archive