where( booleanArray, default )
Returns the indexes where the values in the input array are true.
See also:
true
.where()
function.Keyword | Type | Description |
---|---|---|
|
Boolean Array |
The array of Boolean values to test. |
|
Integer or Integer Array |
The integer number or array of integer numbers to return if none of the values in the array are true. |
Integer Array
This function is useful for finding values in an array that meet a certain criterion. It's also useful for checking the value of a field in an array of CDT field values.
If a default value is not specified and none of the values in the input array are true, an empty list will be returned.
A null or empty array given as the array parameter is considered false.
1
where({true, false, true})
Returns 1, 3
.
When all array values are false and no default is specified, an empty set is returned. For example:
1
where({false, false, false})
Returns {}
.
When all array values are false and a default is specified, the default value is returned. For example:
1
where({false, false, false}, -1)
Returns {-1}
.
1
where(mod({13, 24, 35, 46, 57, 68}, 2)=0)
Returns 2, 4, 6
. mod({13, 24, 35, 46, 57, 68}, 2)=0
returns a list of true and false values based on whether a value is divisible by 2. The where()
function then returns the list of indexes for true values (in this example, the even numbers).
1
2
3
4
a!localVariables(
local!scores: {68, 89, 82, 90, 93, 99, 59, 49, 88, 27, 56, 49, 100},
where(local!scores < 50)
)
Returns {8, 10, 12}
.
1
2
3
4
a!localVariables(
local!scores: {68, 89, 82, 90, 93, 99, 59, 49, 88, 27, 56, 49, 100},
where(local!scores > average(local!scores))
)
Returns {2, 3, 4, 5, 6, 9, 13}
.
1
2
3
4
5
6
7
a!localVariables(
local!scores: {68, 89, 82, 90, 93, 99, 59, 49, 88, 27, 56, 49, 100},
where(
local!scores < average(local!scores) - 3 * stdevp(local!scores),
-1
)
)
Returns -1
because no scores are less than three standard deviations from the mean.
index()
functionThe rule input and CDT shown in this section are for reference only. If you copy and paste either expression, it will not evaluate.
1
2
3
4
5
6
7
8
index(
ri!employees.firstName,
where(
like(ri!employees.department, "Finance"),
-1
),
"None"
)
Returns all of the first names of employees in the Finance department, or "None" if none of the employees have their department field set to Finance.
1
2
3
4
5
6
7
8
9
10
a!localVariables(
local!customer: {
'type!Customer'(riskScore: 1),
'type!Customer'(riskScore: 25),
'type!Customer'(),
'type!Customer'(riskScore: 15),
},
local!customer[where(local!customer.riskScore > 10)]
)
Returns the customer CDTs from the original list with risk scores greater than 15 (the second and fourth customers).
1
where(null)
Returns {}
.
1
where(null, 1000)
Returns {1000}
.
1
where({})
Returns {}
.
1
where({}, -1)
Returns {-1}
1
where({true, false, null, true})
Returns {1, 4}
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 |