How to get a value in a Collection depending on a nested value into this same Collection

Hello markers, my request is quite clear :
Right after an API search call (HTTP module) in a database, I’m getting JSON bundle of results with collections that have always the same structure.

How to get the ID value in the following screenshot depending on Email nested value? In other words, IF email value is “test@gmail.com” in one of those collections, I want the ID value into this collection

Hello @Garry_V,
There are 2 ways to get it.

Using get() and map() functions

{{get(map(map(map(1.data; "widget_data"); "email"); "data"; "data"; "email1@email.com")1)}}

Make sure you change the required input accordingly.

Data I’ve inputted on

{
   "data":[
      {
         "id":1,
         "widget_data":{
            "email":{
               "data": "email1@email.com"
            }
         }
      },
      {
         "id":2,
         "widget_data":{
            "email":{
               "data": "email2@email.com"
            }
         }
      }
   ]
}

On the second approach, you need to use an Iterator. which still needs to use map and get under the lteration.
I think this is enough for you is structure and keys are always same.


:bulb:P.S.: Always search first, Check Make Academy. If this is helpful, mark it as a solution :white_check_mark: and :+1:
Need expert help or have questions? Contact or comment below! :point_down:

Thank you @dilipborad , maybe I didn’t describe very well what I want, I’m trying to reformulate here.

  1. I’m making API call (HTTP module) to get every customer profiles with the name “Sophie”, for instance
  2. I’m getting JSON bundle of results with collections of customers called “Sophie” (like in the previous screenshot)
  3. In this collection of customers, I want to search IF one of them has the following email “sophie.email2@gmail.com
  4. IF the email “sophie.email2@gmail.com” exists is this collection of customers, so I want to get the customer’s ID of the one who has the email “sophie.email2@gmail.com

I know how to target data with get() and map() functions, but I don’t know how to reconciliate one data to another in a entire bundle

Ok @Garry_V,
Based on my last replay I’ve targeted your data array within Bundle 1.
If you’ve multiple bundles which are collections then first use Array Aggregator to combine them all in a single array. Then use Iterator and after that, with that iterator, you can easily use get and map.

If this is not what you want then please share some part of the input data.
:+1:

@dilipborad here the scenario as you describe, but here I’m stuck.

Once I’m able to find out if the array contains email I’m looking for, how “to reverse the process” and reconciliate with the ID?

If the email is static and always the same then put the filter in between the Iterator and Array Aggregator.

1 Like

HHOOOOOO :astonished: that’s crazy!! It works. Thank you so much.

I didn’t know that filter between the Iterator and Array Aggregator works in that way. It’s not exactly the same filter as usual because it can let some data go on. So cool.

2 Likes

Well @dilipborad , so I started testing a bit further and unfortunatly, I got behavior I didn’t expect. Actually, I’ll use a router right after the Iterator.

In one way, IF email is in the collection like you suggested me :

In the other, scenario must go this way IF email is not in the collection AT ALL

And as you can see, I tried several filter conditions (“Not equal to”, “Doesn’t contain”, …) and it goes in both routes anyway :

How to go in one way if the searched email is in the collection, and in other way if the searched email is not in the collection AT ALL ?

Hello @Garry_V,
While you use a Router with multiple routes and using a condition it always goes to that route unless conditions are given and not matched.

Keep in mind that while you use Conditions in Make. Be sure about what type of data comes into that value part and select the condition operator according to a specific type. You can see there are multiple types of condition operators are there.

Another thing is if the first condition is matched and you don’t want to go to another router then use the Fallback Router concept. Which same as IF...ELSE
https://www.make.com/en/help/modules/router#the-fallback-route

If this still does not work then I need to check your Iterator and what the data looks like there.

:+1:

@dilipborad Fallback Router doesn’t work and I know why (thank you by the way, you taught me this option I didn’t know). As there are more than one bundle from the Iterator, 1st route filter check the condition only for the 1st bundle, if it doesn’t fit, it goes to the fallback route.

What I want seems to be quite easy :

Here the output from the Iterator (email is the only variable I want to filter) :

Hello @Garry_V,
I know that this is not a perfect solution but it helps to do further processes and setup the next steps.

Try this attached blueprint.
JSON, Iterator, Route.json (9.8 KB)
In this basic example see the filters that look identical to what you set but also see the last step “Set Variable” where you get the direct ID of the matched item.
After that “Set Variable” you can do further operations.

Also, cross-check the Execution History. Which helps you debug things in more depth.
https://www.make.com/en/help/scenarios/scenario-execution-history

If this is still not solved then please book a call at here. Dilip Borad | Cal.com

1 Like

@dilipborad well, your blueprint gave me ideas, so thank you. I made something not really “conventionnal” but it works so :slight_smile: I use Text Aggregator Module, here it is :

1 Like