SharePoint Online – REST API – Select Taxonomy Field

You can perform basic create, read, update, and delete (CRUD) operations by using the Representational State Transfer (REST) interface provided by SharePoint. The REST interface exposes all the SharePoint entities and operations that are available in the other SharePoint client APIs. One advantage of using REST is that you don’t have to add references to any SharePoint libraries or client assemblies. Instead, you make HTTP requests to the appropriate endpoints to retrieve or update SharePoint entities, such as webs, lists, and list items.

If you have a requirement to select a taxonomy field from SharePoint Designer workflow using Call HTTP action, it is not a straightforward approach. The below article is going to talk about few workarounds for this problem.

My List

list

Note: Job Title is a Taxonomy field.

Problem 1 – Select query will not return Taxonomy Term Label

SPmmdcolumnselect

Problem 2 – Filter query can not be applied against the Taxonomy field.

spmmdcolumnfilter.png

Solution 1 – CAML Based REST Call

The following POST query help you to get the necessary results but the problem with this approach is we can not call this REST Endpoint from SharePoint Designer workflow as it contains curly braces and curly braces are used as tokens in SharePoint Designer.

spmmdcamlquery.png

Solution 2 – Query Taxonomy field value using GUID associated with the Taxonomy TextField

This will be a 3 step process

Step 1 : Get the TextField(hidden note field) value of the Taxonomy Field

Execute the following REST call and note down the TextField value from the REST response

notefield.png

Step 2 : Get the InternalName of the TextField

Pass the GUID of the TextField received from Step 1 in the below REST Call and get the InternalName of the same

intername.png

Step 3 : Get the Taxonomy field value passing InternalName as shown below

getvalue.png

Applying filter against this internal field also leads to the same problem

“The field ‘g9d8145fb42b43f59dd422adf7bbb575’ of type ‘Note’ cannot be used in the query filter expression. ”

A workaround will be to create an additional single line of text field in the list and populate the same with taxonomy field value and use the same to apply filter as shown below

https://yourtenant.sharepoint.com/sites/dev/_api/web/lists/getbytitle(‘Employee Details’)/items?$select=g9d8145fb42b43f59dd422adf7bbb575&$filter=ExtraField eq ‘CEO|6c47210d-44d3-496e-82a3-aaac11a3b94b’

 

 

 

 

 

 

Advertisements

About Joseph Velliah
As a SharePoint Developer my professional interests tend to be technical and SharePoint focused. I run a blog at "SP RIDER" where you can expect to read HOW TOs and scenarios that I run into during my day to day job. I hope my posts will give back a little to the community that is helped me.

Comments are closed.

%d bloggers like this: