length( array )
This function returns the number of elements in an array.
See also:
Keyword | Type | Description |
---|---|---|
|
Any Type Array |
The array in which to calculate the number of elements. |
Integer
In most cases, this function does not count null elements. length({null, 2})
returns 1
because the null is not counted.
There are scenarios though where null values will be counted as part of a list. For example, let's say you have a local variable called local!result
, which stores the results of a query. If the query returns a null value, then the expression length({local!result, 2})
may return 2
. When local!result
is a List of Text String with a single null field, Appian evaluates the expression as length({{null}, 2})
and returns 2
.
If this function is used on a null result from the Query Database smart service, the expression may fail to evaluate and cause an error. To avoid an error, first check the result set for a null value using the isnull()
function before attempting to count the result set using the length()
function.
1
length({10, 20, 30})
Returns 3
.
1
length({10, null, 30})
Returns 2
. Null values are skipped.
1
length({1, 2, merge({1}, {2})})
Returns 3
. Nested lists are counted as one value.
1
length({1, 2, merge({null})})
Returns 3
. Nested lists with only null values are counted as one value.
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 |
length() Function