Check if value is in array?

How do you check if value is in array?

i checked things like
Contains('123',['123'])
and
Contains(['asdf','123'],{"asdf":'123'})
but they don’t seem to check for value (just if path to value exists)

Do i have to recreate find in array like so?:

If(
      IsString(
              Select('asdf', {'asdf':'123'},false)
        ),
  true,'false2'
 )

EDIT: above example doesn’t work for array

If(
  IsString(Select(['asdf'], ['asdf','goo'],false)
    ),
    true,false )

will return false

So how do i check if value is in array?

There is not currently an Array.prototype.includes equivalent.

Here is a workaround I’ve used. It’s a bit convoluted, but works and I think fairly efficient.

IsNonEmpty(Intersection([“term”], [“array”, “of”, “terms”]))
2 Likes

Ok, your example is clearer - i thought in terms of doing:
If(GT(Count(Intersection(['term'],['array','of','terms'])),0),true,false)
but it seems like a lot to just find a value

We are going to release a new family of “contains” functions, such as ContainsField, ContainsPath and ContainsValue. Stay tuned for further updates on that !! :slight_smile:

2 Likes