Using templates with outgoing email


Email templates can help you with outgoing mail from the Email Engine, for example, with email generated from notification actions or escalations. A mail template exported with Developer Studio lists all the available field labels you could use, for example, in creating an outgoing email. For information, see Sending-professional-looking-reply-emails.

You can use content templates with notifications or escalations to arrange the fields and values of the entry that triggered the notification. Content templates used with notifications or escalations can contain the following information:

  • Plain text
  • Variables
    For example, the #$$AR Notification Text$$# variable is replaced by the text entered in the Text field of Notification group in Developer Studio.
  • Core fields
    For example, core fields are replaced with their actual values in the email that is sent out. You use the following syntax with core fields:

    #$$<DatabaseNameOfField>$$#
  • Form fields
    You can use the fields on the form on which the notification action or escalation is based in content templates. You use the following syntax with form fields:

    #$$<DatabaseNameOfField>$$#

    Content templates used with notifications or escalations cannot contain the following information:

  • Keywords — Keyword substitution in content templates is not implemented in Email Engine 7.0.00 and later. As a result, $USER$ or $DATABASE$ in a content template will not be replaced with actual values.
  • Field IDs — Field IDs are not substituted with entry values. As a result, #$$536870925$$# is incorrect. Instead, you should use #$$Id_Integer$$# where Id_Integer is the database name of the field.
    The following example illustrates a content template for outgoing notifications:

    #$$AR Notification Text$$#
    CORE FIELDS:
    -----------------
    RequestId: #$$Request ID$$#
    EmployeeName:#$$Name_Char$$#
    Submitter:#$$Submitter$$#
    ShortDescr:#$$Short Description$$#
    LastModifiedBy:#$$Last Modified By$$#
    Modified Date:#$$Modified Date$$#
    Status:#$$Status$$#
    StatHist-User:#$$Status History.New.USER$$#
    StatHist-Time:#$$Status History.New.TIME$$#
    StatHist-Time:#$$Status History.New.TIME$$#

    Employee Info General Fields:
    ------------------------------
    Employee Name : #$$Name_Char$$#
    Employee Id: #$$Id_Integer$$#
    Employee Salary in Decimal : #$$Salary_Decimal$$#
    Employee Salary in Currency : #$$Salary_Currency$$#
    Employee Gender : #$$Gender_Dropdown$$#
    Employee Marital Status : #$$Marital Status_Radio$$#
    Employee Interests: #$$Interests_Dairy$$#
    Employee Skills : #$$Skills_CheckBox$$#
    Employee Vacation Left : #$$Vacation_real$$#
    PresentOrPermAddChoiceField : #$$PresentOrPermAddChoiceField$$#
    PresentOrPermAddChoiceField : #$$PresentOrPermAddChoiceField$$#
    Joining Details:
    ---------------
    JoiningDate_Date : #$$JoiningDate_Date$$#
    JoiningDateTime_DateTime : #$$JoiningDateTime_DateTime$$#
    Joininig Date_Time : #$$Joininig Date_Time$$#

XML outgoing content templates

You can specify outgoing content templates in XML format, as shown in the following example:

<?xml version="1.0" encoding="UTF-8"?>
<Root>
<NotificationText>#$$AR Notification Text$$#</NotificationText>
<RequestID>ReqId: #$$Request ID$$#</RequestID>
<Submitter>Sub: #$$Submitter$$#</Submitter>
<ShortDescr>SD: #$$Short Description$$#</ShortDescr>
<EmpName>Emp Name: #$$name_char$$#</EmpName>
</Root>

HTML outgoing content templates

You can specify outgoing content templates in HTML format. HTML outgoing content templates can contain graphic images. The following code is an example of HTML outgoing content template that contains a GIF image:

<html>
</Root>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Lighthouse</title>
</head>
<body>
<p><font face="Arial Black"> #$$AR Notification Text$$# </font></p>
<p><img border="0" src="./images/lighthouse.gif" width="174" height="188"></p>
<p><font face="Arial Black"><b>Lighthouse</b></font></p>
<p><font face="Arial Black"> RequestID: #$$Request ID$$# </font></p>
<p><font face="Arial Black"> EmployeeName:#$$Name_Char$$#</font></p>
</body>
</html>

Dynamically assigning templates to outgoing email

The Email Engine gives developers more control over the content and format of email sent from AR System server. Content creation and formatting including the use of graphics are accomplished by designing and storing the templates and images in the AR System Email Templates form. The Email Engine then uses templates stored in this form to format outgoing email.

The Notify filter and escalation action integrates with Email Engine templates, allowing dynamic template assignment. With templates stored as "data in a form," you can see them using workflow. The Templates tab of the Notify action allows you to assign header, content, and footer templates. As demonstrated, you can hard-code these templates by using the template name. You could also dynamically assign templates through a workflow.

Scenario

Apex Global uses four HTML header templates that are already stored in the AR System Email Templates form to provide a banner at the top of outgoing emails that are sent when records are assigned. The templates are designed so that technicians can quickly tell if an incident's impact is urgent, high, medium, or low.

The header template to use for an incident based on the impact

Impact

Template Name

Urgent

Header_Urgent.htm

High

Header_High.htm

Medium

Header_Medium.htm

Low

Header_Low.htm

You can create a data-driven approach to dynamically assign the correct template for the appropriate impact.

The following procedure assumes your Email Engine is properly configured, your users have their own email mailboxes set up, and you have created and stored your templates. This procedure requires that you first create the following AR System server objects:

  • Two regular forms (XYZ Templates and XYZ Incidents)
  • Selection field on templates form
  • Hidden character field on the incident form
  • Filter using Set Fields and Notify actions
  • (Optional) Search menu for template form

To dynamically assign templates to outgoing email

  1. Create a regular form (for example, XYZ Templates).
  2. Add a selection field to the XYZ Templates form.
    This field should use the same attributes you plan to use to determine template assignment. In this example, the Impact selection field attributes are used: Low, Medium, High, and Urgent.
  3. Create a character field, for example, Template Name to store the value of the template to be used.
  4. (Optional) Attach a character field search menu that queries the AR System Email Templates form as a further enhancement.
  5. In a browser, open the XYZ Templates form in New mode.
  6. Create the records for each Impact type, selecting the proper value for the Template Name field.
    Four records are created, one for each of the impact values. 
  7. Create a regular form, for example, XYZ Incidents.
  8. Add a hidden character field, for example, Header Template to the XYZ Incident form as shown in the following figure.
    This field stores the name of the header template to be used with each incident when it is created or modified.

    A form with hidden fields

    xyz-incidents.gif
  9. Create a filter to set the value for the Header Template field on the XYZ Incident form.
    1. On the Basic tab, select XYZ_Incidents as the form.
    2. Select Submit and Modify as the execute conditions.
    3. Enter 'TR.Impact' != $NULL$ as the Run If qualification.
      Here you want the filter to execute on Submit or Modify whenever the value of the Impact field changes, that is, when the filter detects there is a new transaction value in the Impact field.
  10. On the If Action tab, create a Set Fields action with the following parameters:
    1. Read the value for the field from the XYZ_Templates form.
    2. Enter 'Impact' = $Impact$ as the Set Fields Run If qualification.
    3. Select Header Template as the field name and $Template Name$ as its value.
      With this workflow, the name of the proper template, based on its impact, is stored with each incident. Here you define the filter to query the XYZ Templates form created earlier where 'Impact' = $Impact$, and you set the value of the Header Template field on the XYZ Incident form from the value of the template name field on the XYZ Templates form.
  11. On the filter, create a Notify action.
    1. Place the variable $Header Template$ in the Header field.
    2. Enter other parameters as needed, for example, $Submitter$ as the user name, relevant text (including request ID of the ticket), and so on.
      The result of this filter is data-driven automatic template assignment workflow.
  12. In the XYZ Incidents form, create a new ticket (for example, for Joe User) and assign it an urgent value.
    The filter workflow executes and creates a new ticket. This workflow will also create an email notification with the proper header template dynamically assigned based on its impact level.
    When Joe User opens his email client, he receives the following email: 

    An email notification with the Urgent header template

    XYZ-urg-incdt.gif

    You could enhance this with a content template used especially for urgent tickets.

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*