How to search value on JSON?

Hi,

I need to set up an automation allowing users to delete their account from Webflow.

On Webfloiw I made a form that sends a webhook to make. I have the user’s email in this webhook who wants his account deleted. Unfortunately, in order to remove the user from the site via the API, I need his ID number. Email alone is not enough.

{
  "users": [
    {
      "id": "6287ec36a841b25637c663df",
      "isEmailVerified": false,
      "lastUpdated": "2022-05-20T13:46:12.093Z",
      "createdOn": "2022-05-20T13:46:12.093Z",
      "status": "unverified",
      "accessGroups": [
        {
          "slug": "webflowers",
          "type": "admin"
        }
      ],
      "data": {
        "accept-privacy": false,
        "accept-communications": false,
        "email": "Person.One@home.com",
        "name": "Person One"
      }
    },
    {
      "id": "6287ec36a841b25637c663f0",
      "isEmailVerified": false,
      "lastUpdated": "2022-05-19T05:32:04.581Z",
      "createdOn": "2022-05-19T05:32:04.581Z",
      "status": "unverified",
      "accessGroups": [
        {
          "slug": "webflowers",
          "type": "admin"
        }
      ],
      "data": {
        "accept-privacy": false,
        "accept-communications": false,
        "email": "Person.Two@home.com",
        "name": "Person Two"
      }
    },
  ],
  "count": 5,
  "limit": 5,
  "offset": 0,
  "total": 201
}

I therefore ask Webflow API for all registered users. In return, I get all their data (with ID also). I can then compare and search for a user with a specific email address to find out their ID number.

How do this search/comparison in make?

Hi @Maciej ,

To tackle this, consider using the map() function to search for the ID within your array of users based on a specific email. Here’s an example:
F.e.
{{first(map(1.users; "id"; "data.email"; "Person.One@home.com"))}}

If you paste this in your editor, don’t forget to map the users variable to your users variable and of course make the email variable dynamic.

Glenn - Callinetic

3 Likes

Thank you @Callinetic

I also find nice explanation of “map” → Extract an Item from Array | Get and Map Function | Make Beginners Guide

1 Like

OK, I still have a problem with mapping. Maybe you @Callinetic could help me.

I have data in JSON:

And all available data:

I need to get an ID of a specific user email from Webhook at the beginning of the automation. That is why I am mapping in searching of the email from Webhook (red).

Mapping

But in the end, I got an empty bundle on Set Variable.
empy bundle

Where is a mistake?

Hi @Maciej ,

Remove the mapped variable and type as plain text “data.email”. Like my example above.
Monosnap Image 2023-10-23 16-26-46

Glenn - Callinetic

2 Likes

Still empty :confused:

Hi @Maciej ,

If you’re screenshots are still relevant, then I see that the email doesn’t match. The email that you receive through your webhook ends with ed.pl while in you parse JSON result, it’s edu.pl
Can this be the cause?

Glenn - Callinetic

2 Likes

Damn, you are right. :man_facepalming:t2:

Thank you @Callinetic

1 Like