Function that determines if a scheduled distribution has a registration period that begins today.
// Is today a day on which a distribution event should be created for the
// item (a schedule record) being processed?
//
// Return the provided schedule item if the schedule has a distribution event
// scheduled `registration_period` days from today, where `registration_period`
// is a positive integer.
function run({ fields }) {
const today = toString(DateTime.now().setZone("America/New_York"));
const schedule = new Schedule(fields, today);
for (let distributionEvent of schedule.distributionEvents()) {
if (distributionEvent.registration === today) {
// . . .
}
}
return {};
}
- Create a distribution schedule for a given program on Retool
- n8n Workflow pulls distribution schedules from Airtable daily
- For any scheduled events for which registrations open today, the workflow creates an entry in the Airtable distributions sheet.