I am trying to copy a Listitem having Taxonomy column with multi values from one list to another list in a sharepoint online. In the both lists Taxonomy metadata column are created. I am able to get the TaxonomyFieldValueCollection values but some how i am not able to set the values in the destination lists. I have gone through the stackeoverflow post link, but unable to set the Taxonomy values in the Destination list. Below is my code.Iam getting no error
using (var sourceContext = new ClientContext(SourceSiteCollectionurl))
{
sourceContext.Credentials = new SharePointOnlineCredentials(UserName, secure);
List SourceList = sourceContext.Web.Lists.GetByTitle(listName);
Microsoft.SharePoint.Client.ListItem item = SourceList.GetItemById(1);
sourceContext.Load(item);
sourceContext.ExecuteQuery();
TaxonomyFieldValueCollection sourceValue = item["Related_x0020_Party"] as TaxonomyFieldValueCollection;
string ss = "";
List<string> termValues = new List<string>();
foreach (TaxonomyFieldValue taxProductFieldValue in sourceValue)
{
// sb_ProductFieldValue.Append(taxProductFieldValue.TermGuid + "|");
termValues.Add(taxProductFieldValue.WssId + ";#" + taxProductFieldValue.Label + "|" + taxProductFieldValue.TermGuid);
// ss += taxProductFieldValue.Label + "|" + taxProductFieldValue.TermGuid + ";";
}
List targetList = sourceContext.Web.Lists.GetByTitle("Project Department");
Microsoft.SharePoint.Client.ListItem targetItem = targetList.GetItemById(2);
sourceContext.Load(targetList.Fields);
sourceContext.Load(targetItem);
sourceContext.ExecuteQuery();
targetItem["Related_x0020_Party"] = termValues;
targetItem.Update();
sourceContext.Load(targetItem);
sourceContext.ExecuteQuery();
}
Any help Please..
Update: I tried to set the values using List termValues = new List(); but the filed is not updating. No error no output