Zapier loop for each record in view


So, I am trying to write a snippet to use in the code step of Zapier.

Their documentation says

[output] An object or array of objects that will be the “return value” of this code. You can explicitly return early if you like.

Setting the output to an array of objects will run the subsequent steps multiple times — once for each object in the array. If Code by Zapier is the Zap’s trigger and an empty array is returned, nothing happens.

My problem is that this sure looks like an array of objects to me, but Zapier says its not. Any ideas?


Hi @Philip_Bassham

I’m not really a programmer - but I’ve used the Javascript code step to loop through records on many occasions - here is an example:

This brings a comma separated list of record ids from a Link field and converts it into an array of objects - and later steps run for each.

You need to be aware that there is a limit on this ability in Zapier - it will only loop through up to 25 objects. There is a way around this - which is to first split the initial comma separated list into an array of objects each themselves contain a comma separated list of 25 items - and so on.


I actually use that snippet that you wrote, so I am glad you replied.

I am not a programmer either, I just can’t figure out how my output is different from what your output is and not what Zapier wants.



Here is the equivalent output from one of my code steps:

[ { thisReminderObj: { record: [String: ‘recSRKjZTgpQoemE8’] } }, { thisReminderObj: { record: [String: ‘recX3M4SxiEzdCzXY’] } } ]

You’ll see it’s different from yours - the object is called thisReminderObj with a property called record and the object is repeated (an array of objects??). I think yours is simply an array??

Here is the loop that builds it:

do {
var thisReminder = new String(reminderListArray[i]);
var thisReminderObj = {};
thisReminderObj.record = thisReminder;
while (i < reminderNos);


Thanks. I finally got it.

This loops through all the records from a view or search and performs the following steps for each record.


I am basically using code by zapier to loop through my employee database and to send automated birthday email to them. I have used Code by Zapier to loop through the database to find multiple records. I am using schedule by zapier to trigger every hour and capture today’s date and search through the database and send them the email. But, unfortunately, zapier is able to find only one record, even after using the code posted by philip. I am posting the snaps. Could you both please see where am I faulting?


i bet you’re just looking at the results from the test. that just shows the first result found. Once you run it in production, it will process the rest of your actions for each and every response returned.


Hey @openside, Ya I figured that out. Thanks for the reply. But still, my this code is not returning all the results. It is just mailing one particular person multiple times.


Try using Integromat instead - it can read an Airtable table using a formula and return multiple records and then following steps will perform for each.

The only slight pain (with Airtable specifically) is that it sometimes times out in the design process meaning you have to wait a few minutes before continuing - this doesn’t effect the live process though. Airtable / Integromat really need to sort this out because Integromat has far superior logic capabilities to Zapier (conditional branches, loops etc).