Tuesday, 3 November 2015

get_label() or .Label : Retrieve taxonomy column value using JSOM

This is going to be a short post about something I observed recently while working with Taxonomy field and JavaScript object model. While retrieving value of the Taxonomy field of a list item, we generally use the "get_label()" method.

This is the case if you have already referenced SP.Taxonomy.js in your code before fetching the list item. We generally do something like this

It is not necessary to have SP.Taxonomy.js referenced in your code in order to retrieve the Taxonomy field value. If you do not reference SP.Taxonomy.js, you need to use the ".Label" property which is returned with the list item to retrieve the label of the term.

So the next time you are tired of scratching your head trying to figure out why you are not able to retrieve the label using get_label(), check if you have referenced Taxonomy JS and use the appropriate method.

Cheers !

No comments:

Post a Comment