FunctionCopy link to clipboard
wherecontains( values, array )
Receives one or more values and returns an array of indexes that indicate the position of the values within the array.
See also:
- where(): Use this function to return indexes of an array that evaluate to
true
, instead of items that match a user-defined value. - index(): Use this function to return the values of an array at the indexes you gathered with the
wherecontains()
function.
ParametersCopy link to clipboard
Keyword | Type | Description |
---|---|---|
|
Any Type Array |
The values to find. |
|
Any Type Array |
The array in which the values are found. |
ReturnsCopy link to clipboard
Integer Array
Usage considerationsCopy link to clipboard
When to use wherecontains()Copy link to clipboard
This function is useful for finding which items in a CDT array have the same value for a field.
You can then use that array of indexes as the index argument for the index()
function in order to pull the values for another field in that CDT array. This will give you all the values in the second field that have a matching value in the first field. An example is displayed below.
Argument types and formattingCopy link to clipboard
The arguments passed to both the values and array parameters must be of the same type. For example, you can not search through a Decimal Array with a values argument of type Integer.
You can not search through an array of groups or documents with their Integer ID values. Either cast the group/document array to an Integer, or cast the ID values to type group or document.
Matching data typesCopy link to clipboard
The types of values and array must be the same or Appian will return an error. For example, wherecontains(1, {1.2})
will not evaluate since values is an integer and array is a list of decimals.
Understanding resultsCopy link to clipboard
When there is no match, the function returns an empty array.
ExamplesCopy link to clipboard
Find index of value in listCopy link to clipboard
1
wherecontains(20, {10, 20, 30})
Copy
Returns {2}
.
Find index of value in list when value is not foundCopy link to clipboard
1
wherecontains(50, {10, 20, 30})
Copy
Returns {}
.
Find indexes of multiple values in listCopy link to clipboard
1
wherecontains({2, 1}, {1, 2, 2, 3})
Copy
Returns {1, 2, 3}
. Since 2
was found twice in the list, both indexes are returned along with the index of 1
. The indexes returned are in order of the values found in the array.
Find indexes of values in variant listCopy link to clipboard
1
wherecontains({20, "b"}, {10, 20, "b"})
Copy
Returns {2, 3}
Find indexes of complex values in listCopy link to clipboard
1
wherecontains(topaginginfo(1, 1), {topaginginfo(1, 1), topaginginfo(1, 2)})
Copy
Returns {1}
Find index of null values in list of textCopy link to clipboard
1
wherecontains(null, {"a", "", "b"})
Copy
Returns {2}
. Since ""
is equivalent to a null
text value, the second index is returned.
Empty list of valuesCopy link to clipboard
1
wherecontains(tointeger({}), {1, 2, 3})
Copy
Returns {}
.
Use with the index()
functionCopy link to clipboard
1
index(pv!employees.firstName, wherecontains("Finance", pv!employees.department))
Copy
Returns the first names of all employees with their department field set to Finance
or an empty array if none have it set to Finance
.
Text values are case-sensitive.
Feature compatibilityCopy link to clipboard
The table below lists this function's compatibility with various features in Appian.
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 | Custom record fields that evaluate in real time must be configured using one or more Custom Field functions. |
Process Reports | Compatible | |
Process Events | Compatible | |
Process Autoscaling | Compatible |