Zapier integration : Get row ID based on another field

Hello. I usually use zapier + google sheet. I am now trying to work between zapier + glide tables.
I need to find a Row ID based on the Email of a user in the Users table of Glide.
With google sheet integration, I usually do a Lookup spreadsheet row with the email directly. But with Glide integration I can only look for a row only based on the Row ID.
Therefore, in Zapier, I do an action “Get all rows in Glide” so I get all rows, email and the other fields.
But how do I get the right Row ID corresponding to the user’s email I want?

Please help :slight_smile:

Just successfully tested this.

Add a “Code by Zapier” step and choose Run Javascript.

image

Setup the inputs as I have below.

The “search” part will reference the email you want to find the rowID for.

Now here’s the code:

let emails = inputData.emails.split(",");
let rowIDs = inputData.rowIDs.split(",");

let index = emails.findIndex(email => email.includes(inputData.search));

output = {rowID: rowIDs[index]};

I split the emails and rowIDs into arrays, then find the index of the email that matches the search term, and return an index.

I finally return the output as the rowID that match the index I found above.

5 Likes

@ThinhDinh amazing, it works perfect, thank you so much :smiley:

1 Like

Glad to help!

@ThinhDinh :smiling_face_with_tear: Something weird happens here.
It worked well but now I don’t understand why but the javascript doesn’t find the right rowID anymore :
In the report, the rowID is right in the GET ALL ROWS IN GLIDE :
image

However when running the javascript, the rowID is wrong :
image

Here is what the automation looks like. I need to find the rowID to edit it. :

And here the zap CODE BY ZAPIER :

Please let me know if you have an idea what may cause the problem for this one… I have tried many things but this zap finds the wrong rowID.

Do you have any rows that do not contain an email address?

So you’re sure that you don’t have a duplicate email (same as the one you’re searching for), and you don’t have any rows with empty email addresses?

Does the row that have the ID you found (as an error) have any relations with the actual row?

1 Like

@Jeff_Hager @ThinhDinh exact, that may be this. Many email addresses are duplicates and there may be some empty.
Is there anything I can add to the code to fix it ?
Maybe cleaning the index before.

What type of info are you retrieving? Why would there be duplicated addresses?

1 Like

The reason for asking if there are any empty emails is because the array may ignore those empty ones and shift everything in the email array up by one, so after that empty email, all other emails become mismatched with there corresponding RowID.

For example, this:

Becomes this:

Of course, this is just a guess as to what may be happening.

1 Like

This is true, there should not be. I just have another zapier automation that added duplicates. I have cleant the duplicates and empties and it seems like you were right.
Thank you ! Hopefully I am good now.
At least now I know that the table must be clean.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.