Abort or exit automation with script when no records found

Topic Labels: Scripting extentions
1773 2
Showing results for 
Search instead for 
Did you mean: 
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi there,

I have the automation example in Airtable that sends a digest email of certain records for yesterday (in our case, overrun on tasks). On days when there was no overrun, the email would still send but would be blank, which is not appreciated by management.

I found this script in the forums here that helps prevent the email going out BUT it means I get an error alert & email instead, and it makes me go and check the automation is still working:

// A script to stop the automation running when no records are found.
// This prevents blank emails being sent.
// See:

let numRecordsFound = input.config().numRecordsFound;
if (numRecordsFound < 1) {
    throw Error("No records were found. Aborting so no blank emails are sent.")

Is it possible to stop or exit the automation silently, without throwing an error?

Many thanks in advance,

2 Replies 2

Not currently. I agree that the “throw an error to exit” mindset is very counterintuitive (and counterproductive!). Until they add conditional execution and/or branching to the flow of actions, the workaround that I recommend is to split off the email action into its own automation that’s called by a webhook. If it’s designed generically enough, it could be used as part of several automation workflows if you have more than one automation that needs to send an email. The downside is that it eats up your monthly automation allotment more quickly, but it’s worth considering.

I wrote a simple script to send an email to a different email address if no records are found. This way you will not get the error message that the the automation failed.

This post has more info.