0

I am creating a TaxonomyFieldValueCollection as follow:-

TaxonomyField deptField = clientContext.Web.GetList("/sites/Filing/lists/" + "FilingSystem").Fields.GetByInternalNameOrTitle("Fund") as TaxonomyField;
TaxonomyFieldValueCollection tfvc = new TaxonomyFieldValueCollection(clientContext,null,deptField);

but i am not sure how i can add new TaxonomyFieldValue() { TermGuid = f.Id.ToString(), WssId = -1, Label = f.Name } to the tfvc? Thanks

0

We can add values to TaxonomyFieldValueCollection using TaxonomyFieldValueCollection.PopulateFromLabelGuidPairs method

TaxonomyFieldValueCollection tfvc = new TaxonomyFieldValueCollection(Context, null, targetField);

tfvc.PopulateFromLabelGuidPairs(@"label|b3705gudic4dc4071");

tfvc.PopulateFromLabelGuidPairs(@"label2|b705gudicc4565465");

targetField.SetFieldValueByValueCollection(targetitems, tfvc);

targetitems.Update(); context.ExecuteQuery();

More references:

BR, Baker

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.