0

I have a taxonomy field which is muti-allow. I have placed a taxonomy picker control in the application page and the values which are entered in that control are to be set in the list.

My code is as follows:

private void SetFieldValues(SPListItem item)
{
    if (RadViewNewsOffices.Checked)
    {
        TaxonomyField officeField = item.Fields.GetFieldByInternalName(FieldNames.Offices) as TaxonomyField;
        if (officeField != null)
        {
            TaxonomyFieldValueCollection selectedOffices = new TaxonomyFieldValueCollection(officeField);
            selectedOffices.PopulateFromLabelGuidPairs(twtcOffices.Text);
            officeField.SetFieldValue(item, selectedOffices);
        }
    }
}

I debugged the program and getting value at the line officeField.SetFieldValue(item, selectedOffices); that the method is not supported. The text which I am assigning through twtcOffices.Text looks something like:Office 1|098400ee-334a-4b36-b690-a2b77330cc5d;Office 2|8deccb5f-0417-4773-8227-e2a48eae9153.

What should I do to store the value in the taxonomy field?

1 Answer 1

1

Did you try like this:

item[FieldNames.Offices] = selectedOffices;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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