Dec 18, 2017 06:53 PM
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?
Dec 19, 2017 03:14 AM
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.
Dec 19, 2017 03:42 AM
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.
Dec 20, 2017 04:20 AM
Hi
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;
output.push({thisReminderObj});
i++;
}
while (i < reminderNos);
Dec 20, 2017 09:08 AM
Thanks. I finally got it.
This loops through all the records from a view or search and performs the following steps for each record.
Jun 08, 2018 02:42 AM
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?
Jun 08, 2018 10:12 PM
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.
Jun 10, 2018 09:18 PM
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.
Jun 11, 2018 03:57 AM
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).
Aug 13, 2018 01:18 PM
What’s your first step? Airtable “New Record in View”?
I am trying to set up this kind of loop where, once weekly, all new Airtable records in a particular view are sent via gmail. I figured out the Zapier Schedule trigger, but I’m lost when it comes to Code by Zapier’s Input Data. What Airtable trigger is your “Checklist Items” coming from?