Archive for November, 2011

Programmatically write to a taxonomy field

11/08/2011

After several beginner mistakes it turns out it’s quite easy to write to a taxonomy field. Finding the solution took a while though.
The code below writes a term to MyField provided the term is known and the list item is known.

TaxonomyField txField = listItem.Fields["MyField"] as TaxonomyField;
if (txField != null)
{
txField.SetFieldValue(itm, myTerm);
}