Help

Re: Conditional block in email automation

1776 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Lynne_Fetterman
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi all, I have built a simple email automation for our team that triggers upon entering a view. All good there. However, we have one text block in the email that is dependent on the value in a specific field. I have done some digging, and it seems like there should be a way to make this text block appear conditionally, but I am not sure where to begin. I am more familiar with formulas than scripts, but I am guessing an script with an if/then function could work, with something like "If (field X is empty then, " ", “text block”), where I would use the output of the script in the email. Can anyone point me in the right direction, and to where I might find the bones of such a script if this seems workable?

Thanks

4 Replies 4
Joe_Hewes
7 - App Architect
7 - App Architect

Sounds like you could build the text with a formula just as you described…

As @Joe_Hewes indicated, the logic that you just described would work great as a formula. However, it could be simplified. Instead of looking to see if the field is empty, look for it to be full, and only output the desired text if that’s the case. The easy way to do this with an IF() function is using this syntax:

IF({Field Name}, "text block to output if the field is not empty")

This takes advantage of two IF() function shortcuts:

  1. A non-empty field is equivalent to True (most of the time; the exception is a numeric field or any field returning a numeric value, where a zero make the field non-empty, but the value zero is equivalent to false), so literally comparing against an empty string or the BLANK() function is unnecessary.
  2. Omitting the third argument in an IF() function will leave the field blank if the tested condition is false.

In the end, you would put that formula into its own formula field, then insert that formula field into your email template. If the formula outputs nothing, then the text block won’t appear in the email (it won’t even add an extra space). If the text block is created by the formula, it will be inserted into the email.

Thanks Joe and Justin. I should have added that I am trying to avoid the clutter of additional fields, this is a pretty robust base as it is! But using the formula does do the job, ultimately. Is there an advantage over a script?

I certainly appreciate the desire to keep field count low, but you can just hide the fields that you don’t want to see. With a formula field, the value calculates on the fly during other record processing, so it’s ready instantly when the automation begins. Kicking off the JavaScript engine to run a two- or three-line script to calculate a single value feels like more of a waste of resources than an extra field IMO.