Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a managed metadata column in a list. With values in English: Brussel in french: Bruxelles.

I need to compare in the ItemUpdating event the before and after properties. I know that the before cant be used because it will return null in the item updating so I have to use the properties.ListItem.

If the user uses the UI in english, then the following code works fine, because the terms are the same.

However if the user selects french, then this wont work. because the afterproperties will be Bruxelles

private void ValidateAssignmentDate(SPItemEventProperties properties, SPListItem item)
            string currentBudgetSection = properties.ListItem["BudgetSection"] == null ? string.Empty : properties.ListItem.GetTaxonomyFieldValue("BudgetSection").ValidatedString.ToString();
            string newBudgetSection = properties.AfterProperties["BudgetSection"].ToString();
            bool budgetSectionSame = newBudgetSection.Equals(currentBudgetSection);



The extension method is: (I cant change the extension method)

public static TaxonomyFieldValue GetTaxonomyFieldValue(this SPListItem item, string fieldName)

            TaxonomyFieldValue returnValue = null;
                TaxonomyField taxonomyField = GetTaxonomyField(item, fieldName);
                if (taxonomyField != null && taxonomyField.Id != null)
                    returnValue = item[taxonomyField.Id] as TaxonomyFieldValue;
            catch (Exception ex)
            return returnValue;
share|improve this question

1 Answer 1

up vote 0 down vote accepted

I fixed it like this.

string currentBudgetSection = properties.ListItem["BudgetSection"] == null ? string.Empty : properties.ListItem.GetTaxonomyFieldValueByLanguage(item.Web.Site, "BudgetSection", Thread.CurrentThread.CurrentUICulture.LCID).ToString();
            string newBudgetSection=string.Empty ;
            if (properties.AfterProperties["BudgetSection"] != null && !string.IsNullOrEmpty(properties.AfterProperties["BudgetSection"].ToString()))
                 int startIndex = properties.AfterProperties["BudgetSection"].ToString().IndexOf("#")+1;
                 int endIndex = properties.AfterProperties["BudgetSection"].ToString().IndexOf("|");
                 int length = endIndex - startIndex;
                 newBudgetSection = properties.AfterProperties["BudgetSection"] == null ? string.Empty : properties.AfterProperties["BudgetSection"].ToString().Substring(startIndex, length);

 bool budgetSectionSame = newBudgetSection.Equals(currentBudgetSection);
            if((!budgetSectionSame )
//do something
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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