Page tree

Email Templates

Email templates allow you to use and reuse the same email for different records and recipients. Templates are essential for process automation, such as automatically sending an email notifying a user they have been assigned a task or need to approve a contract.

Access to templates is controlled by group permissions. Users who are able to see and use email templates can insert them from the email editor or, if the template is marked Active for the user's team, open them directly from the email icon drop-down menu. If there aren't any email templates visible from the email icon drop-down menu, there might not be any templates for the table, the templates might not be Active for your team, or your group might not have permission to view and send email templates. See Sending Emails for more information.

Manage Email Templates

To see the email templates available for a table, open the table view and select Manage Templates from the email icon drop-down menu.

Email templates list

From here, you can sort and search the table's email templates to find the template you need. You can edit or mass edit existing email templates and create new ones, depending on your permissions.

For more information about creating or editing email template content, see Sending Emails.

Math Operations in Formulas

Formulas in email templates can incorporate basic math operations, such as multiplication, division, and subtraction, using *, /, and -, respectively. For example, you might use subtraction in $formula($field1-$field2).  However, since + is used for concatenation shorthand, you must use SUM() for addition instead.

If you need to show a dollar sign in front of your final result, such as in front of the total sum cost, remember that you need an extra dollar sign to tell the system not to expect a formula or variable. These two dollar signs are placed before the $formula syntax, resulting in a triple dollar sign, $$$formula(), and the result is always rounded to one decimal place, so $$$formula(SUM(17,2)) is rendered as: $19.0

Email Template Formula Reference

In addition to the tools described in Sending Emails, these advanced email formulas are useful for creating templates, especially templates that are sent automatically.

Most formulas work in email templates, but conditional $startif and $if formulas do not. To use conditions in email templates, use a ternary formula instead.

Concatenate Strings

The concatenate strings command allows you to combine field values with text strings, field variables, or other formulas that use variables. For example, if you use $formula(concat("x",$field_name,"z",...)), the "x" and "z" placeholders are where you insert text strings, field variables, or formulas.

It can also be used when inserting a Choice field value, if the value is rendered as code such as 1@2 rather than the text of the value. To do so, enter the value as the only parameter.

Syntax

concat("x",$field,"z",...)

The variables may be text strings, field variables, or other formulas and variables. Text strings must be surrounded in double quotation marks (""), while variables and formulas do not.

If the first piece is a text string, you can use shorthand to combine variables and strings, but $formula() is still required in email templates:

$formula("x"+$variable+"z"+...)

Examples

Example formulaOutput
$formula(concat("Your account representative is ",$account_rep,"."))Your account representative is Hector Gomez.
$formula(concat($company_name," Support Contract"))
Agiloft Support Contract.
$formula(""+$field1*$field2+" Total")2,142 Total
$formula(concat($contract_start_date," to ",$contract_end_date))09/01/19 to 08/31/2020

Formatting Dates and Times

Dateformat() is used to display a date/time field in a particular format, often for localization. Dateformat() takes two arguments: the desired pattern format, and the field variable. Date time patterns are indicated with a series of letters that represent elements such as month, day in month, day of week, year, hour, and minute. For a full list of possible formats see this page from Java about SimpleDateFormat().

Syntax

dateformat("output pattern","$field")

Some common date/time patterns include:

 PatternExample output
"MM/dd/yy"05/31/16
"yyyy/dd/MM"2016/22/09
"MMMMM"July (name of month)
"d"10 (day of month)

Examples

The following results are expected when $contract_start_date evaluates to February 10, 2016 at 01:00:00.

Example formulaOutput
 $formula(dateformat("d",$contract_start_date)) 10. Inserts which day of the month the contract starts.
$formula(dateformat("MMMMM",$contract_start_date))
February. Inserts the full text name of the month.
$formula(dateformat("yyyy",$contract_start_date))
2016. Inserts the year of the contract start date.
$formula(dateformat("MM/dd/yyyy hh:mm",NOW()))Inserts the current date and timestamp when the document template runs.

Check for Empty Fields

The isEmpty operator checks whether a field has a value or not, and is formatted as follows:

isEmpty($field)

This returns true when the $field is null or empty and false if the field has a value.

Ternary Operators

Short conditional statements can be inserted with the ternary operator "a ? b : c." This works like an if-else statement: if the condition "a" evaluates true, then insert "b;" if "a" is false, insert "c." You must provide all parameters for the ternary operator to function, even if one parameter simply inserts a blank space. If you want to output a string in the b or c parameters, include quotation marks around the string.

The ternary operator is useful in formulas that divide by a variable, where that variable might sometimes equal zero. Otherwise, the attempt to divide by zero results in an error. Use the ternary operator to check whether that variable is zero and then provide formulas for each situation. For example, if you want to calculate a percentage using two fields, but $field2 might sometimes equal zero, you could use "$field2 == 0 ? 0 : 100*($field1/$field2)" to output zero if $field2 is zero and otherwise output the calculated percentage.

In some cases, the ternary operator might unintentionally render a Choice field value as code, such as 1@2, instead of the text of the value. To show the text instead, use the concat() function inside the ternary syntax. For example: $formula($choice_field=="Choice A" ? concat($preselected_value_in_choice_field2) : concat($ preselected_value_in_choice_field3))

Syntax

$formula($condition ? "True Output" : "False output")

Example

In this example the statement compares the variable $n to the value 1. If it is 1, "$n is 1" is shown. If it's not 1, "$n is not 1" is shown.

($n==1) ? "$n is 1" : "$n is not 1"

In this example, the statement uses functions inside the ternary formula. This outputs information about the delegation timeline, if the delegation is time-based, and otherwise states that the delegation isn't time-based. Notice that inside the ternary function, $formula is not used a second time.

$formula(($delegation_type=="Time-Based") ? "Delegation from " + dateformat("MMM dd, yyyy", $delegation_start_date) + " to " dateformat("MMM dd, yyyy", $delegation_end_date) : "Delegation is not time-based.")

In this example from an email template, the statement uses images inside the ternary formula. When inserting images, make sure to host them online and insert them as URLs, rather than representing them in base64. Only URLs are compatible with the formula. To host an image, upload it to the image folder in the KB and then link to that location.

<img src='$formula($test_choice_list=="Yes" ? " https://agiloft100.saas.agiloft.com/ui/images/prj_1/gif/greenlight.gif" : " https://agiloft100.saas.agiloft.com/ui/images/prj_1/gif/redlight.gif")'/>