Jul 24, 2021 07:54 AM
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: https://share.support.airtable.com/2NuwnyDD?method=GET
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,
Chris
Jul 24, 2021 08:39 AM
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.
Sep 16, 2021 09:51 AM
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.
Oct 25, 2024 07:26 AM
You can simply "return" the function with nothing. Once returned, the automation will move onto the next step in the sequence.