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:
- 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.
- 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.
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:
- 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.
- 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?
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.