Getting the Localized TaxonomyFieldValue

Let’s say you have a Managed Metadata column in a SharePoint list, and you want to get the value for that column from an item in the list. Easy right?

(item["MyMetadataColumnName"] as TaxonomyFieldValue).Label

One problem though. It doesn’t matter what the current Culture is, you’ll always get back the default label. If you want to get the localized label, you need to do a whole lot more:

  • Create a TaxonomySession
  • Get the Term Store for the site collection
  • Get the term from the guid of the TaxonomyFieldValue
  • And finally… Get the label from the term for the specified culture

Here’s the code:


TaxonomyFieldValue value =item["MyMetadataColumnName"] as TaxonomyFieldValue;

TaxonomySession session = new TaxonomySession(SPContext.Current.Site);

String localizedValue = session.DefaultSiteCollectionTermStore.GetTerm(new Guid(value.TermGuid)).GetDefaultLabel(CultureInfo.CurrentUICulture.LCID);

Comments

3 responses to “Getting the Localized TaxonomyFieldValue”

  1. Arun Avatar
    Arun

    Hi,

    do you know how to get the localized TaxonomyfieldValue in Javascript in SharePoint 2013.

    1. Chris Coulson Avatar

      I would assume you’d follow essentially the same steps with the client side object model, but I haven’t done it so i’m not sure.

Leave a Reply

Your email address will not be published. Required fields are marked *