Copying items with Managed Metadata fields between site collections

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.

Managed Metadata and the Office Document Information Panel (DIP)

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.PopulateFromLabelGuidPair("Netherlands|17E7FDD7-9AAF-4942-BCE1-16f06E40E085");
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;
taxonomyField.Update(true);

Please note that the above code is Full Trust Code. Read this post to know how to set default values from CSOM.