更新TaxonomyField in list using CSOM

public void UpdateTaxonomyField(ClientContext ctx, List list,ListItem listItem,string fieldName,string fieldValue) { Field field = list.Fields.GetByInternalNameOrTitle(fieldName); TaxonomyField txField = clientContext.CastTo<TaxonomyField>(field); TaxonomyFieldValue termValue = new TaxonomyFieldValue(); string[] term = fieldValue.Split('|'); termValue.Label = term[0]; termValue.TermGuid = term[1]; termValue.WssId = -1; txField.SetFieldValueByValue(listItem, termValue); listItem.Update(); ctx.Load(listItem); ctx.ExecuteQuery(); }

猜你喜欢

转载自www.cnblogs.com/xdanny/p/12395788.html