A while ago I came across this very interesting piece of information of properly retrieving a single-select managed metadata column value.
The following is the reference of the article:Taxonomy Columns & REST API
Let us first try to fetch the value of a managed metadata column that allows adding multiple values to it. I have created a simple taxonomy term set called "Countries".
A custom list that contains a column "Country" that is a Managed Metadata column and allows multiple values to be added
The list contains the following values for testing:
Now we try to fetch the list items from this list using the REST API from the provider-hosted app. To use the REST API from the provider hosted app, we need to send the access token in the REST request. This will be used by SharePoint to authorize the call.
We have written the JSON response on our page and we can see that the label of the taxonomy field is retrieved properly.
Now If I change the managed metadata setting to single-select, we see the following difference:
To retrieve this value properly, we need to make use of the GetItems method and SPQuery in the REST request.
And the value will be properly retrieved.
No comments:
Post a Comment