Insert Multiple Records to Airtable with a Loop

Cesar Banchio Updated by Cesar Banchio

Loop to add Multiple Records on Airtable

Sometimes you need to send various amounts of data to Airtable at once, or after you have gathered all relevant data.

For this occasions is that we have developed the following workaround on loops.

The Flow

It's structured in a Question brick, which will the brick in charge of collecting all of our data we want to send to Airtable.

Create an array with all the data collected

For this step, you can either use a code set block, or the set variable block.

Make sure you have the red arrow of the block indicating a possible error.

Once we have done this, and tested it, we can move into the loop.

The Loop

It starts with a message block containing the array of data. This is handy when testing and can be hidden later.

After this block, we are going to get the length of the array with a formula block and store this number in a variable, on the example provided, the variable is named "condition"

Then, we are going to test this condition, if it equals to 0, it means all the data has been uploaded, else, it continues the loop.

If the condition is false, we are going to go through the red path, which we will add 2 code set blocks. One, will get the first element of the array and store it in a variable named "data", and the other will remove this item from the array and store the updated array in the variable we created before "array".

The snippet for the first block is the following:

let res = @array.shift();

return res;

The snippet for the following code set block is:

let res = @array;

res.shift();

return res;

After we collected the data and updated the array, we can insert a message block to render this "data" variable, just for testing purposes, we can then hide it using CSS.

After this, we can insert the Airtable block and set it up so we send this "data" variable to the corresponding column.

It's a good practice to always render an error message if the Airtable block fails like so:

And the green path in the airtable block will be connected to message block displaying the "array".

Test it without hiding the message block where we display "array" and "data" to see that the array is shrinking and the data variable updates on every new iteration.

Template For this Workaround

You can use this template that has the structure ready to save some time and test it. You need to replace the message block with an Airtable block with your account:

Just click here

How did we do?

Get more than 100 items from Airtable

How to Get an Airtable Token

Contact