Using multiple variant criteria on template lines
In Continia Document Output, you can specify precisely what content accompanies your sent documents by defining which variant criteria should be applied to them when they're sent. You set up the criteria on the template lines, and each template line can match on multiple criteria, such as dimensions and field values.
Tip
A criterion is a field value or a filter expression that a field must match. Any template line with several criteria only matches a document that meets all of the criteria.
When a document is sent, the template line with the most matching criteria is used to send the document. If multiple template lines match a document equally well, the one you've given priority is preferred, and if multiple lines have the same priority, the line with the lowest line number will take precedence. If a line has no criteria, it acts as a fallback catching all documents that don't match any other lines with criteria.
By moving variant management from the template header to the line level and allowing multiple variant criteria per line (including combinations of variant fields and dimensions), this functionality offers a high level of flexibility and control. From a single template, you can set up an almost unlimited number of document-sending flows, allowing you to handle content variations that would otherwise require custom code or a separate template for each scenario. You can also filter for values found in other tables with a relation to the primary table in the report on the template, and you can customize accompanying messages in the HTML template for each template line. Also worth noting is that variant values work regardless of the language the setup was made in, and the variant-value limit is up to 250 characters with full filter-expression support.
Overview of relevant features
You set up variant criteria on the Email Template Card, on the Email Template Line FastTab. Here, the Variant Criteria menu offers various options for editing, using, and testing criteria:
| Field | Description |
|---|---|
| Edit Variant Criteria | Allows you to edit the criteria of the selected template line. For more information, see To add or edit the criteria on a line below. |
| Copy Criteria From Line | Copies all variant criteria from another line in the same template and language onto the selected line. You select the line to copy from in the Document Template Lines page and then click OK to apply the selection. |
| Clear Criteria | Removes all variant criteria from the selected line, turning it into a catch-all. |
| Check for Overlaps | Checks the selected line's criteria against every other line for this template and language, and reports which lines could also match a given document. |
| Test Match Document | Lets you pick a real document and reports which line of the template would actually be used to send it (or that none would). |
Edit Variant Criteria is arguably the most important one of these options, as it provides access to the assisted Variant Criterion Setup guide. This is described in more detail in To add or edit the criteria on a line below.
Besides the Variant Criteria menu, the table on the Email Template Line FastTab also features a number of columns that are relevant to the variant-criteria feature:
| Column | Description |
|---|---|
| Description | Shows what a template line matches on, by listing the criteria that have been applied to the line. Each criterion (that is, each pair of field and filter value) is separated from the next by a comma. |
| Priority | Breaks ties between lines that match a document equally well. The column enables you to assign a priority to the template line, which will then come into effect when multiple lines have an equal number of matching criteria. The lowest priority wins, so if you give a line Priority = 0, it will be preferred over other lines with Priority = 1 or higher. For more information, see To prioritize criteria lines below. |
| Variant Criteria Count | Shows how many criteria a template line has. The actual criteria are listed under Description, as described above. |
Note
The lowest Priority value wins in case of ties, and if multiple lines also have the same priority, the line with the lowest Line No. wins. A line with no criteria at all functions as a catch-all: it's used when no other line matches, but a line with even one matching criterion is preferred over it. A line that isn't enabled is never matched.
To add or edit the criteria on a line
In order to add variant criteria to a template line or edit the existing criteria of a line, follow these steps:
Search () for and select Email Templates.
In the list of templates, in the Code column, select the template you want to edit. The Email Template Card opens.
On the Email Template Line FastTab, select the line to edit, or click Manage > New Line to add a new line, and then in the action bar, click Variant Criteria > Edit Variant Criteria to open the Variant Criteria page.
Tip
Alternatively, you can select the Description column of the line to go straight to the Variant Criteria page.
You can also click Manage > Copy Line to copy the default template line and then Add Criterion to open the assisted Variant Criterion Setup guide. If you do, proceed to step 5 below.
In the action bar, click Add Criterion to add a new criterion, or click the Field column of an existing criterion to edit it. The assisted Variant Criterion Setup guide opens.
In Selected Field, click the three dots (or click Select Field in the footer) to open the Fields (With Relation) page, allowing you to choose the document field that the criterion reads.
In the list of fields – or using the Search field at the top – locate and select the field that should be read. Then do as follows:
If the selected field itself should be read by the criterion, proceed to step 7 below.
If the criterion should rather read a field in a related table (that is, a field that the document doesn't contain itself, such as a dimension value or a field on the customer), click Next in the lower-right corner to open the table that's related to the selected field. Then locate and select the field to be read in the related table, and proceed to step 7 below.
Note
When you use a related table and click Next, the Selected field at the top will display the path – that is, the name of the original table followed by the selected field. The name of the related table is then displayed in Table Name.
Click Finish. One of the following will happen:
If no related table is used, the selected field is assigned and you're returned to the Variant Criterion Setup guide.
If a related table is used and the records in it are identified by one field, the field is assigned and you're returned to the Variant Criterion Setup guide.
If a related table is used and the records in it are identified by more than one field, the Specify Key Field Values page opens. In the Value field, enter or select (using the three dots) the specific record that you want to filter with, and then click OK to return to the Variant Criterion Setup guide.
Note
The path in Selected Field is slightly different from the one in step 6 above: It displays the field selected in the original table, followed by the name of the related table (with the selected filter record in brackets, if applicable), which is then followed by the field selected in the related table.
Select Next to continue to the next step of the guide. In Filter Value, enter or select the value or filter expression that the field must match.
Tip
Standard Business Central filter operators work here. Note that if you enter an applicable filter value as free text, it will be automatically translated into the corresponding code value, so that the value works across different languages. For example, if you enter "Yes" as a filter value for the Handled (DO) field, it will be changed to true.
Under This Criterion, the Criterion field shows how the criterion reads, and Overlap shows any other lines a document matching it would also match. Under Try It Out, to optionally check (without sending anything) whether a real document satisfies the criterion, click the three dots next to the Test with Document field, and then select a document from the list.
Note
If the selected document matches the criterion, This Document Reads will specify the value with which the selected field matches the criterion in the document, and Criterion Matches will read Yes – this document would match.
Click Finish to save the criterion.
Repeat steps 4-10 for any additional criteria you want to add to the template line.
You've added or edited one or more criteria on the selected template line, and they'll now be used for sending any document matching them (provided that no other lines with matching criteria take priority). To add additional criteria to the same template, go to the Email Template Card > Email Template Line FastTab, click Manage > New Line or Copy Line, and then repeat the entire process, starting with step 3 above. To prioritize any of the lines with criteria, see To prioritize criteria lines below.
To prioritize criteria lines
If you want to make sure that a template line with variant criteria is given a higher or lower priority than other potential lines that match a document equally well, follow these steps:
- Search () for and select Email Templates.
- In the list of templates, in the Code column, select the template you want to edit. The Email Template Card opens.
- On the Email Template Line FastTab, go to the line that you want to prioritize.
- Under Priority, enter the priority number that you want to assign to the selected line. The lower the number, the higher the priority, meaning that 0 is the highest priority.
The template line is now prioritized according to the priority you've given it. The priority will take effect if the criteria of multiple lines match a document equally well.