a!flatten() Function

Function

a!flatten( array )

Converts an array that contains other arrays into an array of single items.

Parameters

Keyword Type Description

array

Any Type Array

Array to be flattened.

Returns

Any Type Array

Usage considerations

Understanding results

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.

Examples

Remove nesting from arrays

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}

Remove only array nesting

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 ) )
}

Retaining data types

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

The table below lists this function's compatibility with various features in Appian.
Feature Compatibility Note
Portals Compatible
Offline Mobile Compatible
Custom Record Field Expressions Compatible
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.

Open in Github Built: Fri, Sep 23, 2022 (01:20:36 PM)

On This Page

FEEDBACK