Skip to main content

I ran into a strange problem in an automation.

I am using a script to gather some data from two tables and combine it into a rich-text field. In the next step, I send out an e-mail with the content of this field. Turns out the e-mail is sent before the script has updated the text field!

Even adding a 3 second delay in the script does not solve the issue.

Curious if someone has a solution in place?

Thank you!

Hey @Miles11!

This actually strange, and I do not see how that is possible unless your email gets triggered on a different automation (e.g. when the rich text field is not empty, or when it is updated).

However, you might want to explore including some sort of "Output.set()" on your script, and using the value obtained from such output on the body of the email -rather than the actual data from the updated field.

Please let me know if this is somehow helpful, or otherwise feel free to provide further context.

Best,
Mike, Consultant @ Automatic Nation


The problem is not the actions running out of order. That is why adding a delay does not fix the issue. 


The send email action is getting the field value from when the automation was triggered, not the value when the action is run. 

There are two basic solutions. Pick whichever makes the most sense to you. 

Do a fresh read of the record after the script executes with a “find records” action. Grab the field value from the “find records” action, not the trigger. 

- Have your script output the value using output.set(). Use the value outputted by the script in your email. 


Hey @Miles11!

This actually strange, and I do not see how that is possible unless your email gets triggered on a different automation (e.g. when the rich text field is not empty, or when it is updated).

However, you might want to explore including some sort of "Output.set()" on your script, and using the value obtained from such output on the body of the email -rather than the actual data from the updated field.

Please let me know if this is somehow helpful, or otherwise feel free to provide further context.

Best,
Mike, Consultant @ Automatic Nation


Hi @Mike_AutomaticN

Thank you, using output.set() in the script was the method I tried and makes much more sense in this context.

Thanks for your help!


The problem is not the actions running out of order. That is why adding a delay does not fix the issue. 


The send email action is getting the field value from when the automation was triggered, not the value when the action is run. 

There are two basic solutions. Pick whichever makes the most sense to you. 

Do a fresh read of the record after the script executes with a “find records” action. Grab the field value from the “find records” action, not the trigger. 

- Have your script output the value using output.set(). Use the value outputted by the script in your email. 


Hi @kuovonne ,

Thank you, so helpful! Have a better idea now how these things work in AT

xMiles


The send email action is getting the field value from when the automation was triggered, not the value when the action is run. 
Hi ​@kuovonne 
This is incredibly helpful and is exactly where I am getting stuck. I couldn’t understand why a delay didn’t work so your answer above finally makes sense.

I am using a script to update an Attachment field, and then trying to send an email (using Outlook: Send Email integration). But the email is not using the updated Attachment (as you point out above). I tried your Find Record method but when I try to reference it for the attachment in Outlook: Send Email, it only offers to “flatten” the array rather than attach the attachments).

Any advice gratefully received. Thank you so much!


I tried your Find Record method but when I try to reference it for the attachment in Outlook: Send Email, it only offers to “flatten” the array rather than attach the attachments).

 

Yeap if you flatten it it’ll look like this and it’ll attach all the files as expected:

 


Reply