Programmatically create a Document Set content type


  using (SPSite site = new SPSite("WEBURL"))
                {
                using (SPWeb web = site.OpenWeb())
                {
                //create the new document set contenttype
                SPContentType newDocumentSet = web.ContentTypes.Add (new SPContentType(web.ContentTypes["Document Set"],web.ContentTypes,
                "MydocumentSet"));
                //get a an instance of DocumentSetTemplate for the new document set
                DocumentSetTemplate newDocumentSetTemplate = DocumentSetTemplate.GetDocumentSetTemplate(newDocumentSet );
                //add allowable content types
                newDocumentSetTemplate.AllowedContentTypes.Add
                (web.ContentTypes["Document"].Id);
                //add a shareable property
               // newDocumentSetTemplate.SharedFields.Add(newDocumentSetContentType.Fields["Module"]);
                newDocumentSetTemplate.Update(true);
                newDocumentSet.Update();
                web.Update();
                }
                }

Comments

Post a Comment

Popular posts from this blog

IRM and the Object Model

This content database has a schema version which is not supported in this farm

Activate and Deactivate Feature through PowerShell