MAP_LAMBDA

Return an array that is the result of calling lambda with each element of the input array or each key-value pair of the input object.

Syntax 

MAP_LAMBDA(array_or_object, lambda)

Usage examples 

Example 1

Construct an array of elements from input array.

Input

1
{
2
"my_action": {
3
"email_array": [
4
"foo@tines.com",
5
"bar@tines.com"
6
]
7
}
8
}

Formula

MAP_LAMBDA(my_action.email_array, LAMBDA(elem, OBJECT("email_address", OBJECT("address", elem))))

Output

1
[
2
{
3
"email_address": {
4
"address": "foo@tines.io"
5
}
6
},
7
{
8
"email_address": {
9
"address": "bar@tines.io"
10
}
11
}
12
]

Example 2

Construct an array of elements from input object.

Input

1
{
2
"my_action": {
3
"my_object": {
4
"foo": [
5
1,
6
2,
7
3
8
],
9
"baz": [
10
4,
11
5,
12
6
13
]
14
}
15
}
16
}

Formula

MAP_LAMBDA(my_action.my_object, LAMBDA(key, value, OBJECT("key", key, "sum", SUM(value))))

Output

1
[
2
{
3
"key": "foo",
4
"sum": 6
5
},
6
{
7
"key": "baz",
8
"sum": 15
9
}
10
]

Sample Actions 

Transform
My Action
Transform
MAP_LAMBDA

Select an action to inspect

You can also click "Copy actions" and paste them in your Tines story to see how they work.

Was this helpful?