How to add comma separated values from text component to query's "IN"

I have a text component where users can enter order ids separated by commas:



Then in a query, I want to make a where clause where I use it in clause “IN”.

I’ve tried this:

 (true = {{ order_ids.value == "" }} OR IN ({{ order_ids.value.split(',').map(i => parseInt(i)) }}))

I was assuming I need to convert it to an array first and then convert each one to the integer.

But this doesn’t work. The is an integer in DB.

The error I’m getting:

invalid input syntax for integer: "{NULL}"

Hey @ckissi! Your current code for that split operation is going to output an array, which isn’t going to work here - you’ll need to use the ANY keyword:

OR = ANY({{ order_ids.value.split(',').map(i => parseInt(i)) }})
1 Like