SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a scenario where I'm provisioning a document on the server after collecting some metadata.

Environment is SharePoint 2010 and Office 2010.

The SharePoint list item and file are created correctly. The SharePoint list item has all of the proper metadata assigned in SharePoint.

However, when opening the document in Word 2010, the DIP shows that the managed metadata fields are blank, even though they have the correct value in SharePoint. If I save the item in SharePoint through the UI, it works like a charm and the managed metadata properties (taxonomy fields) are fine if I open it in Word again.

If I try to call SPFile.Update(), SPListItem.SystemUpdate() or SPListItem.Update(), it has no effect on pushing the properties down to the document.

I've found that in the case where the managed metadata properties don't stick, the XML of the document looks like this:

    <RegionTaxHTField0 xmlns="3a290427-a0ba-4a8f-bf50-36a9ad2bef07">
        <Terms xmlns=""></Terms>

After saving the item in the UI, the XML looks like this:

    <RegionTaxHTField0 xmlns="3a290427-a0ba-4a8f-bf50-36a9ad2bef07">
        <Terms xmlns="">
            <TermInfo xmlns="">

Unforunately, there isn't a whole lot of documentation on this TermInfo element out there on the web. I'm trying to figure out how I can get SharePoint to generate those extra elements (instead of doing it in OpenXML) since, obviously, SharePoint can do it.

Ideas and pointers would be much appreciated!

share|improve this question
up vote 0 down vote accepted


Need to use the SetFieldValue method of the TaxonomyField class in Microsoft.SharePoint.Taxonomy.dll:

    private static void UpdateTaxonomyFields(SPFile target, List<TaxonomyField> taxonomyFields)
        SPListItem item = target.Item;
        SPSite site = item.Web.Site;

        TaxonomySession session = new TaxonomySession(site, false);

        foreach(TaxonomyField t in taxonomyFields)
            TermStore termStore = session.TermStores[t.SspId];

            TermSet termSet = termStore.GetTermSet(t.TermSetId);

            string value = Convert.ToString(item[t.Id]);

            string[] parts = value.Split('|');

            value = parts[parts.Length - 1];

            Term term = termSet.GetTerm(new Guid(value));

            if(term == null)
                Log.Write("Term could not be found for value \"{0}\"", value);

            t.SetFieldValue(item, term);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.