locked
Rest API filter multiple value filed such as lookup/choice RRS feed

  • Question

  • I want to filter multiple value filed such as lookup/choice but I found multiple value is not working in Rest $filter, is there any workaround for this ?
    Friday, November 1, 2019 3:33 AM

Answers

  • Unfortunately you can't use REST query on status field, because the type of the field is choice. In SharePoint it's not allowed to create a lookup to point to the choice field, this is root cause of such behavior.

    But hopefully it is possible to use lookup with calculated text column.

    So you can workaround your issue by creating calculated column inside Client list, say StatusCalc with formula =Status. The main purpose of this field is simply showing the value of corresponding choice field.
    Now you can use REST as following:

    _api/web/lists/getbytitle('temp')/items?$select=client/StatusCalc,Title,Id&$expand=client&$filter=client/StatusCalc+eq+'my choice'

    Below article for your reference:

    https://sharepoint.stackexchange.com/questions/118633/how-to-select-and-filter-list-items-lookup-column-with-sharepoint-2013-rest-feat/118659

    Thanks & Regards,


    sharath aluri

    Friday, November 1, 2019 3:50 AM
  • Hi zhw12,

    SharePoint Rest API not support multiple value field filter:

    A workaround is to filter with CAML Query and do a Post Request like this demo:

    SharePoint REST API: CAML Query

    More information:

    SharePoint REST API Limitation

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Friday, November 1, 2019 9:34 AM

All replies

  • Unfortunately you can't use REST query on status field, because the type of the field is choice. In SharePoint it's not allowed to create a lookup to point to the choice field, this is root cause of such behavior.

    But hopefully it is possible to use lookup with calculated text column.

    So you can workaround your issue by creating calculated column inside Client list, say StatusCalc with formula =Status. The main purpose of this field is simply showing the value of corresponding choice field.
    Now you can use REST as following:

    _api/web/lists/getbytitle('temp')/items?$select=client/StatusCalc,Title,Id&$expand=client&$filter=client/StatusCalc+eq+'my choice'

    Below article for your reference:

    https://sharepoint.stackexchange.com/questions/118633/how-to-select-and-filter-list-items-lookup-column-with-sharepoint-2013-rest-feat/118659

    Thanks & Regards,


    sharath aluri

    Friday, November 1, 2019 3:50 AM
  • Hi zhw12,

    SharePoint Rest API not support multiple value field filter:

    A workaround is to filter with CAML Query and do a Post Request like this demo:

    SharePoint REST API: CAML Query

    More information:

    SharePoint REST API Limitation

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Friday, November 1, 2019 9:34 AM