I'm trying to copy a list item from one list to another. The lists are on the same site and the code is being fired inside of an item added/updated event receiver).
Both lists have managed metadata fields mapped to the same term sets.
Everything works as excepted until I try to set the Managed Metadata fields.
SPListItem newItem = destinationList.Items.Add();
newItem["Title"] = oldItem.Title;
//Assign the rest of the non-taxonomy field values
newItem.Update();
SetTaxononmyField(newItem, myTaxonomyFieldValue, "fieldname");
newItem.Update();
-
private void SetTaxononmyField(SPListItem newItem, TaxonomyFieldValue value, string fieldname)
{
TaxonomyField field = newItem.Fields.GetFieldByInternalName(fieldname) as TaxonomyField;
if (field != null)
{
field.SetFieldValue(newItem, value);//Throws "Specified method is not supported" exception here
}
}