Zurück

Use variants of email templates

  • 9 Min.

We often want the emails and attachments sent to customers to be different, depending on criteria like the size of the account, or their industry. For example, we have different terms and conditions for our small customers versus our large customers. How can this be automated so that I’m not checking every email before sending it?

Ester, Accountant at Cronus

Many companies have groups of customers and vendors that need differentiated email messages and attachments. These types of differentiated templates are managed in Document Output when you create and enable variant email template lines, rather than creating completely separate email templates for the same document type. This is because each document type can connect to only one email template.

Scenario

In this scenario video, Ester sets up two variant email template lines to cater for different customer needs.

Ester needs to work on these tasks:

  • Attach a different terms and conditions document to sales invoices for the customer group: large.
  • Create a variant sales order email for updated versions of the original order.

You can differentiate variant email template lines by dimension and field values, which you source from the document itself, or on related tables like the Payment Method or Country/Region tables. For example, you could create variant email template lines based on a combination of:

  • Dimension values, such as Business Group or Sales Campaign.
  • Field values, such as Number of emails sent or VAT Country/Region.
  • Language codes.

Hinweis

Variation by language code is covered in the following learning unit.

Variant email template lines can differentiate from the default email template in many ways, including:

  • Additional or different merged PDFs, such as additional terms and conditions.
  • Text and merge fields in the email body, for example an alternate signature with a campaign message.
  • Report format, for example Word or Excel instead of the default PDF.
  • PDF password (if you have activated the Document Output Security Module and enabled PDF Password Protection).
  • From email.

In the example image of the sales invoice email template, you can see:

  • Line 2 set up for the Customer Group dimension, with the value: Small.
  • Line 3 set up for customers with the language code: DEU.
DO Learn Mod 1-25-E-Mail Template Card E-Mail Template Lines FastTab

Hinweis

The first email template line operates like a default line. This should always be left without a selection for language field and without one of the dimension codes, so that documents not covered by a variant template will still be sent with the main version of the email template.

Set up variant template lines

Start creating a new variant template line with the Copy Line action in the Manage action menu. An assisted setup guide will take you through the necessary steps.

  1. Click the Add Criterion action.
Email template card Copy Line Add Criterion
  1. Select a field number from the document header list.
    • If the field has a Relation, you can click Next to select a field from the related table instead of the document header. You can continue to use related tables until you find the relevant field.
    • When you have found the field relevant to creating the variant, click Finish.
Fields with relation relation table next finish
  1. Click Next to open the Variant Criterion Setup.

    • At the Filter Value, you can enter a value from a list, or use standard Business Central filter criteria if relevant.

    • In the This Criterion section, you can check the details of the field and value, and see if Document Output has identified any overlaps with other variant filters setup.

Variant criterion setup Filter value Criterion Overlap
  1. Click Finish to return to the start of the assisted setup guide. You can add further criteria to the same email template line from here, or click OK to apply the criterion.

Test variant template lines

You can test out your criterion setup using your current documents, without the need to send or alter the document in any way.

  • From the Variant Criterion Setup screen in the assisted setup guide, select a document at the Test with Document field. This Document Reads shows the value identified in the document, and Criterion Matches shows whether the document would meet the criterion.
  • From the Email Template Lines FastTab, use the Test Match Document action in the Variant Criteria action menu. Select a document from the list, and then a dialog box shows which template line would apply and state the relevant document field and value found on the document.

Check for overlaps and set priorities

When you configure a number of variant email template lines, it’s possible that a document meets the criteria for more than one line. In the example below, the same document could potentially meet the criteria for:

  • customer group = small on line 20000, and also
  • salesperson = BC on line 30000

Document Output identifies these overlaps, and lets you set a priority level on each line to help clarify which variant to use in these cases. In the example below changing the priority of line 30000 to 1 means that line 20000 with priority 0 will have priority when there is a document with overlapping matching criteria.

GIF Check overlaps set priorities

Other resources

More learning resources for this topic include: