holds the multiple values of the taxonomy field. I have a string like 2;#Department 2|c98ce851-88fd-41bc-a013-4a69dd6bae66 and assigning it using PopulateFromLabelGuidPairs() but I am not able to see the term stored in it.
My code is:
TaxonomyFieldValueCollection newDepartments = null;
TaxonomyFieldValueCollection oldDepartments = properties.ListItem[FieldNames.Department] as TaxonomyFieldValueCollection;
string strNewDepartments = Convert.ToString(properties.AfterProperties[FieldNames.Department]);
if (!string.IsNullOrEmpty(strNewDepartments))
{
TaxonomyField deptField = properties.List.Fields.GetFieldByInternalName(FieldNames.Department) as TaxonomyField;
if (deptField != null)
{
newDepartments = new TaxonomyFieldValueCollection(string.Empty);
newDepartments.PopulateFromLabelGuidPairs(strNewDepartments);
}
}
I debugged the code and found the strNewDepartments = 2;#Department 2|c98ce851-88fd-41bc-a013-4a69dd6bae66 but when I watched newDepartments[0].Label it shows "" (an empty) value. I writing this code in ItemUpdating event receiver of a list that's why I took the string of the field.
What am I missing?