Problem
I have a SiteType Taxonomy field in the “ApproverList” list. I want to filter using the REST call. I get the following error.
“The field ‘SiteType’ of type ‘TaxonomyFieldType’ cannot be used in the query filter expression.”
I am surprised that REST call for taxonomy filed is not allowed. But I found an alternative.
Solution
Here is I have created an alternative solution for this problem.
- Created a hidden text field for each Taxonomy field. E.g. BusinessUnit will have hdnTxtBusinessUnit
- Created a workflow for OnItemNew and OnItemUpdate
- Workflow is to find “|” pipe character in the BusinessUnit_0 field.
- Extract the Term values before the “|” character. E.g. “HR|{guid}” extract HR
- Update the hdnTxtBusinesUnit with extracted value. i.e. “HR”
- Now to make the REST quries use the hdnTxtBusinesUnit field.
The following is the screen shot of the workflow steps.
I hope this helps.
Clever.
This might be simpler: http://sharepoint.stackexchange.com/questions/98827/rest-query-managed-metadata-filter
It uses a REST POST instead of a GET, but it does filter on managed terms without a calculated field or workflow. Here is a copy of his snippet:
var taxoField = “Status”;
var taxoValue = “Completed”;
restUrl = appWebUrl + “/_api/web/lists/getbytitle(‘” + listName + “‘)/GetItems(query=@v1)?@v1=” +
“{\”ViewXml\”:\”” + taxoValue + “\”}” +
select;
$.ajax(
{
url: restUrl,
method: “POST”,
headers: {
“Accept”: “application/json; odata=verbose”,
“X-RequestDigest”: $(“#__REQUESTDIGEST”).val()
}
}
);