Search Arrays for Related Data

Scenario: I have a google sheet that has two columns, phone number and name:

image

I want to be able to lookup the name based on the phone number.

Using a google sheets node, I'm able to grab the data as an array:
image
image

Now, I'd like to be able to search through all of the sub-arrays using a phone number and find the matching name that corresponds to it.


To say it another way, I already have the phone number (in this case an incoming text from Twilio) and I want to be able to look up the name in this sheet using that phone number regardless of its position in the sheet. (to eventually use it in a customized response - that part I can handle, I'm just stuck on how to search through and find the match.)

Any ideas on the best way to accomplish this?

You can use a Function node using the Javascript find() method on the array

msg.payload = msg.payload.find( el => el[0] == "12222222" )
return msg;
1 Like

This worked perfectly. Thank you so much!

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