Examples:
-
map(Emails[];email)
Returns a primitive array with emails
-
map(Emails[];email;label;work;home)
Returns a primitive array with emails having a label equal to work or home
For more information, see Map an array or array element.
shuffle
sort (array; [order]; [key])
Sorts values of an array. The valid values of the order
parameter are:
-
asc
(default) - ascending order: 1, 2, 3, … for type Number. A, B, C, a, b, c, … for type Text
-
desc
descending order: …, 3, 2, 1 for type Number. …, c, b, a, C, B, A for type Text.
-
asc ci
case insensitive ascending order: A, a, B, b, C, c, … for type Text.
-
desc ci
case insensitive descending order: …, C, c, B, b, A, a for type Text.
Use the key
parameter to access properties inside complex objects.
Use raw variable names for keys.
To access nested properties, use dot notation.
The first item in an array is index 1.
Examples:
-
sort(Contacts[];name)
Sorts an array of contacts by the “name” property in default ascending order
-
sort(Contacts[];desc;name)
Sorts an array of contacts by the “name” property in descending order
-
sort(Contacts[];asc ci;name)
Sorts an array of contacts by the “name” property in case-insensitive ascending order
-
sort(Emails[];sender.name)
Sorts an array of emails by the “sender.name” property
reverse (array)
The first element of the array becomes the last element, the second becomes the next-to-last, and so on.
flatten (array)
Creates a new array with all sub-array elements concatenated into it, recursively, up to the specified depth.
distinct (array; [key])
Removes duplicates inside an array. Use the “key” argument to access properties inside complex objects. To access nested properties, use dot notation. The first item in an array is index 1.
Example: distinct(Contacts[];name)
Removes duplicates inside an array of contacts by comparing the “name” property
toCollection
-
This function takes an array containing key-value pairs and converts it to a collection. There are 3 arguments to the function:
-
(array) containing keyvalue pairs
-
(string) the name of the field to use as key
-
(string) the name of the field to use as value