REST call error ‘The field ‘SiteType’ of type ‘TaxonomyFieldType’ cannot be used in the query filter expression.’

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.”

pic1

 

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.

pic2

I hope this helps.

 

 

About Pankaj

I am a Developer and my linked profile is https://www.linkedin.com/in/pankajsurti/
This entry was posted in Uncategorized. Bookmark the permalink.

1 Response to REST call error ‘The field ‘SiteType’ of type ‘TaxonomyFieldType’ cannot be used in the query filter expression.’

  1. Andy Gettings says:

    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()
    }
    }
    );

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s