Oct 30, 2020 06:03 PM
Is it possible to only complete an action based on the output of a previous action? I would like to run a script when a field is updated, but I want to send an email based on the output of the script. If the script runs and doesn’t find any conflicts I don’t want to send an email.
In this case I don’t really see a way to break out of an automation or send an email inside a script other than using outside API calls.
How would you accomplish this? Would Airtable throw errors if I just put in a blank email in the to: field so that the step is executed, but it doesn’t actually send to anyone?
Oct 30, 2020 06:22 PM
Use two automations and an email table. Have the first automation run the current script. If there should be an email, have the script create a record in the email table. Then have a second automation watch to email table and actually send the email.
Oct 30, 2020 07:56 PM
That is a nice workaround. There are just so many tables in the base already. I wish you could hide tables or communicate between bases more seamlessly.
Thanks @kuovonne you seem to always have the answer lol.
Oct 31, 2020 05:43 AM
One more idea - send the unnecessary email to a dead-end address.
Nov 05, 2020 09:14 AM
Yea that is a good idea. I was wondering what was better dead-end address or just a blank address. I assume Airtable might give an error if the email address is blank, but I think it would just show a failed automation run or maybe I can just handle the error.
Nov 05, 2020 02:30 PM
How would you decide what email address to use and where would you store it? Airtable automations currently don’t have branching, so the dead-end email address would need to exist in the same location as the valid email addresses. You could use another formula field for this, but adding fields creates clutter too.
Do you want to include the output of the script in the email? For example, does the script generate text that you want in the email? If so, I believe that the automation will use the field values that existed at trigger time, not any values that were updated by the script after the automation was triggered.
Nov 05, 2020 02:34 PM
Why?
let emailAddress = (field.address === null) ? "deadend@domain.com" : field.address;
Nov 05, 2020 02:41 PM
Because the code that you wrote is code. It is not something that you can put in the “to” field when configuring a email action in Airtable.
Nov 05, 2020 02:43 PM
Doesn’t the email action have the ability to utilize the results of a previous script process in the action?
Nov 05, 2020 02:46 PM
The email action in Airtable automations is a completely different action from the scripting action. As far as I can tell, scripting actions have no outputs that are accessible in the automation chain.