During a recent project we did some investigations around installing apps to a SharePoint 2013 site programatically, which is not possible at this moment.
One of my colleagues (Jeroen van Lieshout) wrote a detailled blog post about this, so visit his blog for the details.
When you update the default column values for a content type, these new values are not pushed to the document template of the content type if you’re using a customized document template (e.g. mytemplate.dotx). New documents created using the document template will still have the old default values attached to it. To push the changes to the customized document template you can execute one of these steps:
- Via the UI: Open the “Advanced Settings” page of the content type and click “OK”;
- Via code: Get you SPContentType and execute this code (this simulates the UI step):
SPContentType ct = SPContext.Current.Site.RootWeb.ContentTypes[YOURCONTENTTYPEID];
ct.DocumentTemplate = ct.DocumentTemplate;
When you download a document with taxonomy fields from site collection A and then upload it again into site collection B, the taxonomy values on the documents might not be set correctly. The values are displayed, but in the wrong column. To prevent this, two steps can be taken by the user:
- After the download, remove the “Document Properties and Personal Information” from the document via the “Inspect” option in Office. When the document is uploaded again, the default values from the new site collection will be used.
- Copy the document from site collection A using the OOTB “Copy To” functionality. Now SharePoint takes care of setting the taxonomy fields correctly.
Some background information: the taxonomy field value is linked to the “TaxonomyHiddenList” of site collection A via the ID in the hidden list. Once the document is moved, the ID remains the same but on site collection B this ID might be linked to another term as the “TaxonomyHiddenList” values can be different.
When you update any Managed Metadata column values from either CSOM of Full Trust Code, you need to make sure to make the Taxonomy value GUID lower cased. Otherwise it will cause the Office Document Information Panel to display an invalid default value (in red). Example code to update a default value, while ensuring the GUID is lowercased is shown below:
SPField field = SPContext.Current.Web.Fields["CustomMMSfield"];
TaxonomyField taxonomyField = (TaxonomyField)field;
TaxonomyFieldValue defaultValue = new TaxonomyFieldValue(taxonomyField);
defaultValue.WssId = -1;
// GUID should be stored lowercase, otherwise it will not work in Office
defaultValue.TermGuid = defaultValue.TermGuid.ToLower();
// Set the selected default value for the site column
taxonomyField.DefaultValue = defaultValue.ValidatedString;
Please note that the above code is Full Trust Code. Read this post to know how to set default values from CSOM.