Updating SharePoint Taxonomy Fields

I tripped up on it a bit recently on SharePoint taxonomy fields (or managed metadata fields) as I found that I wasn’t able to push down values from a SharePoint list item to a Word document programmatically in SharePoint.

I was able to set the property in SharePoint and the list item would reflect the property in string form like so:

But the problem with this is that when the user opens the document, the Document Information Panel (DIP) will not have the value pre-selected.  All of the other values are set properly and show up in the DIP.  I found that if I saved the item manually in SharePoint through the UI, it would push the changes down to the Word document, but it took quite a while to figure out how to set the taxonomy field values.

In the Word document itself, I could see that the document properties were clearly different.  The first code block shows what a functioning document properties XML looks like:

And here is what it looks like if you set the property using the string value only:

I chased this around for hours trying to figure out how to set the field values in SharePoint so that they’ll be pushed down into the Word document.  It turns out, there’s a new API for handling taxonomy fields.  The following sample assumes that you’ve iterated through the fields and collected all of the taxonomy fields:

Using this approach, you can set the property in SharePoint and push it down to the document as well.

You may also like...