a!flatten( array )
Converts an array that contains other arrays into an array of single items.
Keyword | Type | Description |
---|---|---|
|
Any Type Array |
Array to be flattened. |
Any Type Array
a!flatten()
removes nesting from arrays, such as those created by looping functions. When passed a simple array, a!flatten()
returns it unmodified.
Nulls are not removed from lists. Use reject() and isnull() to easily remove nulls from a flattened list.
a!flatten()
always returns an array, so when passed a single item, a!flatten()
returns an array containing that item.
When passed an empty or null array, a!flatten()
returns an empty array.
If the passed array is type Any Type, a!flatten()
returns an array of the appropriate type.
a!forEach(items: {1, 2, 3}, expression: enumerate(fv!item))
returns a 3 item list consisting of {0}
, {0, 1}
, and {0, 1, 2}
a!flatten(a!forEach(items: {1, 2, 3}, expression: enumerate(fv!item)))
returns {0, 0, 1, 0, 1, 2}
Only array nesting is removed when using a!flatten
. Nested maps, dictionaries, and data types retain their structure.
1
2
3
4
5
6
7
a!flatten(
{
a!map( id: 1 ),
a!map( id: 2 ),
a!map( id: 3, address: a!map( street: "Main Street", number: 101 ) )
}
)
returns:
1
2
3
4
5
{
a!map( id: 1 ),
a!map( id: 2 ),
a!map( id: 3, address: a!map( street: "Main Street", number: 101 ) )
}
typename(typeof(a!flatten({a: {1, 2, 3}}.a)))
returns "List of Number (Integer)"
typename(typeof(a!flatten({a: {1, 2, "apple"}}.a)))
returns "List of Variant"
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 | Incompatible | You cannot use this function to configure a process report. |
Process Events | Incompatible | You cannot use this function to configure a process event node, such as a start event or timer event. |
a!flatten() Function