Best answer

How to find a matching record from Airtbable using a Webhook response array

  • 23 November 2021
  • 6 replies
  • 42 views

Hi !!

I’m very new to this community but have been a Zapier user for years. However, I’m a no-coder so today I’m in very need of help on how to process something I want to do with a Zap.

 

The idea here is to Find an Airtable record that matches a specific condition, the latter being pulled from a previous API Call using a Zapier Webhook.

 

First Step, my trigger is when a new invoice is created in Airtable. No issue there :-)

Second step, I’m calling Airtable API with Webhook with custom parameters. In the response, I have fields that I want to use as a filter in the 3rd step , see below :

 

 

Now,  for Step 3 I want to Find any random record in Airtable that IS NOT one of the User_ID’s from Step 2. As the result of API call is an array, I don’t quite figure how to push this array as a Filter for the records I’d like to pull from Airtable.

In a Step 4, once a record is pull, I’d like to create a New record in Airtable with previous steps’ informations.

I saw a couple of topics pointing in the right direction, but all of them used Loops and it’s not applicable in this case and I don’t get how I can handle this.

I saw this thread https://community.zapier.com/general-questions-3/only-continue-if-logic-issue-with-array-field-9529?postid=43577#post43577 but it doesn’t seem to help.

Any ideas would be a life saver ;-) 

Thank you for your help.

Best,

D

icon

Best answer by Troy Tessalone 23 November 2021, 17:28

View original

6 replies

Userlevel 7
Badge +12

Hi @Yanovski 

How many results are returned in the Array?

Not sure you’ll need to use the Airtable API for this.

The Airtable Find Record action has the ability to search by a Search Formula: https://support.airtable.com/hc/en-us/articles/218151657

 

You may need to use a Code step to prep the data from the Array to format for inclusion into the Airtable Find Record Formula and/or Airtable API request since there are a variable number of array results returned to handle.

EXAMPLE

 

Hi @Troy Tessalone !

Thank you for your reply ! 

As of today, we just have a couple of results in the array. But tomorrow, it can be hundreds.

However, can you please help me with the below ? :

 

 

You may need to use a Code step to prep the data from the Array to format for inclusion into the Airtable Find Record Formula and/or Airtable API request since there are a variable number of array results returned to handle.

 

I understand the Filter by Formula idea but I don’t have a clue on how to provide something like this in this field :

NOT({User_ID} = “User_ID_1 from previous step'', {User_ID} = “User_ID_2 from previous step''), and so on…..

Or even the AND({User_ID} != “User_ID_1 from previous step'', {User_ID} != “User_ID_2 from previous step''), and so on…..

Thank you very much

Y

Userlevel 7
Badge +12

@Yanovski 

WARNING: Hundreds might be troublesome.

You’ll also need to code for other use cases such as 0 results returned from the array of IDs to exclude, as well as how to handle if there are 0 results returned from the Find Record / API Request.

 

Code step

 

Results

 

Wow @Troy Tessalone this is awesome.

However, if I may, you set a fixed number of items in your code step….So I assume this won’t be scalable if I have let’s say 10 records to exclude right ?

Thanks,

Y

Userlevel 7
Badge +12

@Yanovski

Code is dynamic

Just map the dynamic value from the trigger step array for the comma separated Airtable Record IDs to replace “N1,N2,N3”.

 

The FOR loop runs for the length of the array. (In my example, it was 3 loops)

NOTE: You’d need to change the {Name} to the label for the field header you are referencing but make sure to keep enclosed in brackets { }

 

@Troy Tessalone 

This is marvelous…..Such strong support and reactivity is wonderful.

You rock !

Best,

Y

Reply