How to check if a value is inside an array in the expression tag editor?

Hello Forum,

in my expression tag, I need my tag to have this value:

Let's say I have a value x and I want to check it if it's inside an array or no.
so basically the expression will be:

x in myArray

how can I do that in my expression tag?

Thank you

Did you try lookup()?

Hadn't tested it and not sure about your tag type.

If it's a string array (it maybe works with other array types as well, haven't tested this) and your gateway version is 8.1.8+, you could use the expression function indexOf.

1 Like

thank you for your response, I already tried this one and it didn't work, my array in a hardcoded array of integers

if it's hardcoded, consider using a dataset tag with a lookup() expression.

1 Like

indexOf is absolutely the solution here and works regardless of array/list type as long as the value you're looking up also matches that type.