contains( array, value )
Checks whether an array contains the value.
Keyword | Type | Description |
---|---|---|
|
Any Type Array |
Array to check. |
|
Any Type |
Value to look for. |
Boolean
contains({1, 2, 3}, 2)
returns true
Values are matched case sensitively:
contains({"A", "b", "c"}, "A")
returns true
contains({"A", "b", "c"}, "a")
returns false
contains({1, 2.2, 3.3}, todecimal(1))
returns true
Cast the integer value to a decimal using the todecimal()
function so that the two inputs are of the same type. Not doing so results in the error message Invalid types, can only act on data of the same type
.
contains({1, null, 3}, tointeger(null))
returns true
When the value is an empty list of the same type, true
is returned:
contains({1, 2, 3}, tointeger({}))
returns true
contains(tointeger({}), tointeger({})
returns true
contains({1, 2, 3}, {1, 2})
returns true
contains({1, 2, 3}, {1, 4})
returns false
To return the indices where the values match, use wherecontains()
:
wherecontains(2, {1, 2, 3})
returns an array with 2
All fields of the dictionary must match the fields of one of the values in the array:
contains({{a: 1, b: 2}, {a:3, b: 4}}, {a:1, b: 2})
returns true
contains({{a: 1, b: 2}, {a:3, b: 4}}, {a:1})
returns false
contains({{a: 1, b: 2}, {a:3, b: 4}}, {a: "1", b: 2})
returns false
Feature | Compatibility | Note |
---|---|---|
Portals | Compatible | |
Offline Mobile | Compatible | |
Sync-Time Custom Record Fields | Compatible | Can be used to create a custom record field that only evaluates at sync time. |
Real-Time Custom Record Fields | Incompatible | |
Process Reports | Compatible | |
Process Events | Compatible |
contains() Function