2023 May 14 2:46 PM
Hi, I'm using OData client v2 for my VUEJS app and trying to filter like this
$format=json&$top=50&$filter=substringof('COFFE', searchKey) and (origin eq 'BRA' or origin eq 'COL')
according to this light OData documentation we can use in() like this
$filter=substringof('COFFE', searchKey) and origin in ('BRA', 'COL')
the first one with 'OR()' works, but the second with 'IN()' unfortunately is not working, any idea?
Hi, I'm using OData client v2 for my VUEJS app and trying to filter like this
$format=json&$top=50&$filter=substringof('COFFE', searchKey) and (origin eq 'BRA' or origin eq 'COL')
according to this light OData documentation we can use in() like this
$filter=substringof('COFFE', searchKey) and origin in ('BRA', 'COL')
the first one with 'OR()' works, but the second with 'IN()' unfortunately is not working, any idea?
2023 May 14 3:27 PM
klaudry
According to this Stack Overflow post, the correct syntax for using the in() operator in OData is as follows:
$filter=substringof('COFFE', searchKey) and (origin eq 'BRA' or origin eq 'COL')
CopyThe syntax you mentioned is incorrect:
$filter=substringof('COFFE', searchKey) and origin in ('BRA', 'COL')
CopyI hope this helps. Let me know if you have any other questions.
2023 May 15 12:01 AM
Since your URL has "substringof" rather than "contains", I assume that the server is implementing OData V2.
The "in" operator is defined only since OData V4, e.g. http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#_Toc31360968
(Even then, a V4 server might or might not support it).
So for a V2 service using the "or" operator might be the only available choice.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |