Skip to main content Skip to complementary content

Managing custom notifications

To customize the email body you will need to be able to understand and manipulate the HTML. You can import one of the templates as a starting point and these will help you understand the approach to the layout of the template. There is a reason for the structure we have used as each email client renders HTML differently so nesting the tables is the best approach to ensure it is consistent in each client. Of course, you are welcome to use whatever structure you require but we would suggest you test on multiple email clients to ensure it is consistent.

Custom notification / subject line

The custom notification/subject is the push notification message for the mobile and the subject line in an email. This enables you to target the message with enough information to act without having to open the body of the record. To give you an idea of how to use this field we have provided the following examples.

In the table below we provide some examples of how you can construct your notification message with simple text and/or using the dynamic variables:

Dynamic variable example uses
Example Notification/Subject code example
Plain text

ALERT : You're about to run out of stock

Using the alert name

ALERT : {{alertName}}

Single alert example

ALERT : {{measures.0}} is {{conditions}} !

Drill to dimension alert example

ALERT : {{nRows}} {{dimensions.0}} with {{measures.0}} {{conditions}} !

See the Dynamic text variables section below for a full list of those that can be used in the notification messages and the email message body.

Email body requirements and examples

There is one key requirement when you are using a custom email body message. You must include the full HTML code syntax structure as outlined below for the email to construct correctly. Use the preview button to review your code to see the structure you have created.

<!DOCTYPE HTML >
<html lang="en">
<head> .... </head>
<body> .... </body>
</html>

Importing example templates

If you have the option of importing an HTML template file into the custom editor so you have a starting example to adapt. You can use one of the following template files, which are copies of the standard templates that are included in the Qlik Alerting installation, to load into this editor.

Dynamic text variables

The following are a list of text variables that can be called in the notification/subject and/or body of your customized notification. There are also more complex looping elements you can use which are covered in the next section.

Dynamic text variables
Variable label Variable code Description
Recipient Name {{firstName}} Provides the name of the user to whom the triggered notification will be sent. This can be the owner of the alert, the broadcast alert recipient or the managed shared alert recipient.
Alert ID {{alertId}}

Provides the Alert ID (GUID) which is used in the unsubscribe URL link. This is not normally presented but may be useful for debugging purposes.

Alert Name

{{alertName}}

Provides the name of the alert record.

Alert Triggered Timestamp

{{timestamp}}

Provides the timestamp when the alert was triggered in Qlik Alerting.

Alert Measure

{{measures.0}}

Provides the measure name that is scanned for the alert. This can be either the master item label or the entered label for advanced Qlik expressions.
Alert Measure Current Value {{values}}

Provides the current value of the measure at the time of the scan.

Information noteThis variable does not exist for drill to dimension alerts.
Alert Condition {{conditions}}

Provides the conditions that the scan will check against to trigger the email. This is shown as a string.

Unsubscribe from Alert URL {{unsubscribe}}

Provides the URL which can be clicked on to unsubscribe to the alert. Allowing users to opt out of an alert if they do not feel it adds value for them.

Qlik Alerting login URL

{{qlikAlertingLink}}

Provides the URL which can be used as a link to go straight to the Qlik Alerting login screen on the web portal.

Qlik Sense Application Name {{appName}}

Provides the name of the Qlik Sense application which the alert will scan.

Qlik Sense Application ID {{appId}}

Provides the ID of theQlik Sense application which the alert will scan.

Qlik Sense Application URL Link (with filters) {{appLink}}

Provides a URL link to the Qlik Sense application which includes the filters and sheet reference as setup in the alert (or derived by the Qlik Alerting extension for Qlik Sense).

Qlik Sense Server {{qlikLink}}

Provides the URL which can be used as a link to go straight to the Qlik Alerting login screen on the web portal.

Looping elements

There are two types of loops that are used in our default templates. These are used for filters, and the arrays of values associated with them, and for the drill to dimension results.

Example: Filter table

This loop example shows all fields that have filters assigned to them (the #query.filters loop) and the values assigned to them (the #values loop):

<table style="color:#494848; font-size:13px; line-height:1.8; table-layout:auto; width:100%;">
	<tr style="background-color: #fff">
		<td style="width:40%"><strong>Field</strong></td>
		<td><strong>Selections</strong></td>
	</tr>
	{{#query.filters}}
		<tr style="border-bottom:1px solid #dfdfdf;">
			<td>{{field}}</td>
			<td>
				<table style="padding:0px; font-size:13px; width:100%">
					{{#values}}
					<tr>
						<td>{{.}}</td>
					</tr>
					{{/values}}
				</table>
			</td>
		</tr>
	{{/query.filters}}
</table>

Example: Drill to dimension results

There is one loop in this example as it is returned as one array of data, the #dimensionValues loop:

<table style="color:#494848; font-size:13px; line-height:1.8; table-layout:auto; width:100%;"> <tr style="background-color: #fff"> <td><strong>{{dimensions.0}}</strong></td> <td><strong>{{measures.0}}</strong></td> </tr> {{#dimensionValues}} <tr> <td>{{qText}}</td> <td>{{qNum}}</td> </tr> {{/dimensionValues}} </table>

Embedding web images into emails

A common request, particularly if you are sending alert emails to external organizations, is to be able to embed a logo or other images into the body of the alert. The answer is of course “Yes, you can!”

To add this functionality you can change the HTML and add an <img> tag as per the example below.

<table width="100%">
    <tr>
        <td align="center" style="padding:10px 25px;">
            <div style="text-align:right">
		<img src="https://qlik.imgix.net/us/-/media/images/qlik/global/qlik-logo-2x.png?h=94&w=308&la=en&hash=91B8028A8CF991CF3864E421063D49298BD58575" alt="Qlik Logo" height="64">
            </div>
        </td>
    </tr>
</table>

Right to left language support

The email templates can be adapted to provide right-to-left language support for Arabic, Aramaic, Azeri, Dhivehi/Maldivian, Hebrew, Kurdish (Sorani), Persian/Farsi and Urdu. In order to enable this you must change the <style> code at the start of the template. There are two places that you will need to adjust to ensure the template works in right to left format. You will of course need to change the text, the labels and be using an application that is built using the language of your choice.

Example: Default left-to-right CSS

<style type="text/css">
	div {
		direction: ltr;
		text-align: left;
		vertical-align: top;
		font-family: Tahoma, Ubuntu, Helvetica, Arial, sans-serif;
	}

	table, th, td {
		direction: ltr;
		text-align: left;
		border-collapse: collapse;
		mso-table-lspace: 0pt;
		mso-table-rspace: 0pt;
		word-break:break-word;
		vertical-align:top;
	}
</style>

Example: Changes for right-to-left CSS

<style type="text/css">
	div {
		direction: rtl;
		text-align: right;
		vertical-align: top;
		font-family: Tahoma, Ubuntu, Helvetica, Arial, sans-serif;
	}

	table, th, td {
		direction: rtl;
		text-align: right;
		border-collapse: collapse;
		mso-table-lspace: 0pt;
		mso-table-rspace: 0pt;
		word-break:break-word;
		vertical-align:top;
	}
</style>

Updating default email templates

The default email templates are shipped with the Qlik Alerting installer. However, it is possible for an organization to edit these base templates so that the default emails (and those templates that are imported into the custom editor) are customized for your organization.

Important:

  • You will need to have remote desktop access to the Qlik Alerting server, or to the C:/Program Files drive folder on this server.
  • You must have edit rights to the files in this location.
  • These changes will need to be migrated when you upgrade Qlik Alerting. You will need to make copies of them and then replace the new templates that will be copied as part of the upgrade. Ensure that you check if any variables have been updated as you may need to make some changes to your templates over time.
  1. Navigate to the C:/Program Files/Qlik Alerting/email-messenger/templates folder (default install path).
  2. Make a backup copy of the file you wish to edit.
  3. Edit the .hjs files in any text editor, change the language type when viewing the file to HTML to make it simpler to read.
  4. Save and test by creating and triggering an alert.

Which files relate to which emails

Email types and templates
Email type Created email template Triggered email template
Single measure data alert dataCreate.hjs data.hjs
Drill to dimension data alert dimensionCreate.hjs dimension.hjs
System alert systemCreate.hjs system.hjs

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!