Skip to main content

FLATTEN

Flattens an array of arrays into a single array, one level deep.

Syntax​

FLATTEN(array)

Arguments​

  • array: An array whose elements are themselves arrays (for example, one array per child record).

Example​

FLATTEN([[1, 2], [3], [4, 5]]) → Returns [1, 2, 3, 4, 5].
FLATTEN([[{a: 1}], [{a: 2}, {a: 3}]]) → Returns [{a: 1}, {a: 2}, {a: 3}].

A common use is combining a packed-object field collected from every child record of every child record — for example, every Invoice's own array of Financial Ledger entries, gathered at the parent Invoice Group level:

FLATTEN(C@CURRREC!N@Invoice!{{Packed Ledgers}})

Usage Notes:

  • FLATTEN only removes one level of nesting. An element that is itself a doubly-nested array is left nested: FLATTEN([[1, [2, 3]], [4]]) → [1, [2, 3], 4].
  • Non-array input returns an empty array [].
  • FLATTEN does not sort, filter, or deduplicate, it only combines. Use FILTER, SORTBY, or GROUPBYSUM on the result if needed.