Forum Discussion
Hi Angela,
There is an "in" operator that you can see a use case of at the end of this blog. This example is for querying on collections of items, though I'm pretty sure it would be possible for an array of strings like you're proposing. I still need to test this myself (still getting my test instances set up), but I believe the syntax would be something like the example below:
https://beautifulplm.com/test/server/odata/MagicItemType?$filter=in(serial_number,('9879','678','643','123','234')).
- Daan8 months agoIdeator I
Off-topic: happy to see you are back(?) christopher_gillis!
- AngelaIp8 months agoIdeator I
Indeed! There is an IN operator! It´s even mentioned in the latest REST API guide. See "Extended condition in".
But I am not sure if it´s really designed for my use case. Your example unfortunately didn´t work.
"IN" seems to be used to get additional information from linked item properties. Useful, but different use case.The IN operator needs some additional arguments. I did some testing. Something like this works technically:
https:// ; xxx / yyy /server/odata/MyItemType?$select=serial_number,bpl_psid&$filter=in(id,$root/MyItemType($select=id;$filter=serial_number eq '123' or serial_number eq '456' ),id)
@All: My variant is just a test and not supposed to be a role model example of how to use the IN condition! Please check Chris' mentioned blog article and the official REST API guide for examples! Right now this query does the same than my original sample above, just with an additional layer of complexity. Note that I use the same repeating structure to create the OR condition!
christopher_gillis You don't have to put much work into this! The original variant works perfectly. Note that I love to over-optimize trivial tasks. Daan can confirm that. [emoticon:c4563cd7d5574777a71c318021cbbcc8]
If there is an alternative option, I would be happy to use it. But the previous variants works perfectly already.