Get Value From Array of collections where Other Value equal to some@email

:bullseye: What is your goal?

I want to get Response Status from the Attendees Array where email is developer@gmail.com

:thinking: What is the problem & what have you tried?

I tried figuring using array functions but was not able too.

:camera_with_flash: Screenshots (scenario flow, module settings, errors)

Hey there,

you need the first(map()) function combo to dynamically find and pull data from the array.

In your case it will be something like first(map(Attendees;response_status;email;developer@gmail.com)). Dont copy paste this directly, instead select the first and map functions from the menu and fill in your exact variables.

2 Likes

Hi thanks for replying but this didnt work. I think this will help you more:
“attendees”: [
{
“email”: “email1@gmail.com”,
“self”: true,
“responseStatus”: “declined”
},
{
“email”: “developer@gmail.com”,
“organizer”: true,
“responseStatus”: “accepted”
}
]

I tried with this:
{{map(6.attendees; “responseStatus”; “email”; “developer@gmail.com”)}}

tried with first too

Map will return a primitive array. You need to apply first on top of it to get the item itself.

2 Likes

Welcome to the Make community!

Combining Map & Get (or First) functions to get Values from Arrays

The built-in functions map, get, first (or `last) allows you to access values within an array containing collections.

First, use the map function on an array, which returns another array of filtered values —
map(array; key; [key for filtering]; [csv-values for filtering])

Then, the built-in function get (or first/last) to get a specific, single item from the resulting array —
get(array; path)

You will get something that looks like these —

{{ get(map(array; "value"; "name"; "content-type"); 1) }}
{{ first(map(array; "value"; "name"; "content-type")) }}

Map Function Parameters: Step-by-Step

To easily remember how to use each of the parameters of the map function, think of it this way:

  1. From this array (of collections),
  2. I want to get all the the values for the property/key named _______,
  3. Where another property/key _______
  4. has the exact case-sensitive value _______

Example

1. From this array (of collections) user_column_data

2. I want to get all the the values for the property/key named string_value

3. Where another property/key column_id

4. has the exact case-sensitive value EMAIL

5. Output

e.g.:

{{ first(map(5.user_column_data; "string_value"; "column_id"; "EMAIL")) }}

:high_voltage: Make Input Markup: Copy-paste the above into the field, including start/end curly brackets for it to import as intended :warning:

Using Join Function to Transform an Array into a Single Text Variable

You can also combine map with join to join the values into a single text string —
{{ join(map( ... ); delimiter) }}

e.g.:

{{ join(map(array); ", ") }}

For more information, the documentation for the above functions can be found in the Help Centre and the “Mapping with Arrays” link below. You should also complete the tutorials in the Make Academy, especially Using get() and map() functions as this is the most important knowledge you need to understand so that you can successfully apply it when building scenarios using Make.

Links & Guides

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I’d also recommend going through the Make Academy if you haven’t yet!

Learn Make

How-Tos

— @samliew
P.S.: investing some effort into the tutorials in the Make Academy will save you lots of time and frustration using Make!