Question

I would like to get the items whose field A is IN (X,Y,Z...).

I've seen ways to do it with ORs (Rest API - $filter multiple values) but is there a simpler way?

Something like:

/_api/web/lists/getbytitle('Students')/items?$select=Title,ZIP&$filter=(ZIP IN [111,222,333,444])

Thanks!

Était-ce utile?

La solution

You can use IN operator in CAML query with SharePoint REST API's GetItems endpoint.

Example of IN operator uses:

<Where>
  <In>
    <FieldRef Name="ID" />
    <Values>
       <Value Type="Number">1</Value>
       <Value Type="Number">2</Value>
       .
       .
       .
       <Value Type="Number">530</Value>
    </Values>
  </In>
</Where>

References:

  1. In element (Query)
  2. Make CAML query with in rest api call
  3. SharePoint REST API - CAML Query
Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top