I’m working on a Zapier automation to create multiple dated records in Airtable. My goal is to make a script that takes two dates and outputs all the dates in between. Zapier says returning an array of objects should process each item separately, but it’s not working as expected.
Here’s what I’ve tried:
function getDates(start, end) {
let dates = [];
let current = new Date(start);
let finish = new Date(end);
while (current <= finish) {
dates.push(current.toISOString().split('T')[0]);
current.setDate(current.getDate() + 1);
}
return dates.map(date => ({ date }));
}
const result = getDates(inputData.startDate, inputData.endDate);
return result;
The script runs, but Airtable only creates one record with all dates combined. It works if I use a text field, but not with date fields. Any ideas on how to fix this? I want each date to create a separate record in Airtable.
I’ve run into similar issues with Airtable and Zapier before. One trick that worked for me was to modify the script to return an array of objects with more fields, not just the date. This seems to help Zapier recognize each item as a separate record.
This way, you’re creating a unique object for each date with additional fields. The ‘created’ field adds a timestamp, and ‘status’ is just a placeholder. You can adjust these as needed.
Also, double-check your Zap configuration. Make sure you’re using the ‘Create Multiple Records’ action in Airtable, not just ‘Create Record’. This action is specifically designed to handle arrays of objects.
If that doesn’t work, you might need to set up a loop in Zapier itself to iterate through the dates and create records one by one. It’s less elegant but can be more reliable in some cases.
I’ve encountered this issue before when working with Airtable and Zapier. The problem likely stems from how Airtable interprets the date format you’re sending. To resolve this, try modifying your script to format the dates explicitly in a way Airtable recognizes:
function getDates(start, end) {
let dates = [];
let current = new Date(start);
let finish = new Date(end);
while (current <= finish) {
let formattedDate = current.toISOString().split('T')[0];
dates.push({ 'Date': formattedDate });
current.setDate(current.getDate() + 1);
}
return dates;
}
This approach creates an array of objects, each with a ‘Date’ key. Make sure your Airtable field is named ‘Date’ as well. Also, double-check that you’re using the ‘Create Multiple Airtable Records’ action in Zapier, not the single record version. If issues persist, consider using Zapier’s built-in looping feature to process each date individually.
this might help zapier recognize each item as separate. also double check ur using the ‘Create Multiple Records’ action in airtable, not just ‘Create Record’. hope this helps!