Email Notifications

From QPR ProcessAnalyzer Wiki
Revision as of 17:02, 9 February 2021 by Ollvihe (talk | contribs)
Jump to navigation Jump to search

Notifications send automatic email messages based on defined rules, for example when there are deviations in the process requiring actions. Notifications are defined for models, and each model can contain several notifications. Notifications are sent based on the following logic:

  1. The optional filter is applied to the model data, or if there is not filter defined, the entire model data is used.
  2. If notifications are meant to be sent to different recipients with different content for each recipient, the data can be optionally divided into dimensions (notifications will be sent for each of the dimension values).
  3. If the email subject or body needs to contain dynamically changing information based on the actual data, measures can be defined which are calculated for each of the dimension values.
  4. As last, a criteria defining for example a threshold value, is applied for each of the dimension value (i.e. a potential notification), and based on it actual notification email is either sent or not. Dimensions and measures can be used in the criteria expression (as variables by their names).

When working with the notifications, the notifications first need to defined, requiring to define e.g. criteria for sending the email and the email message contents. When notifications are in place, the sending (or triggering) the notifications need to be scheduled using a script (alternatively a user-initiated triggering from the UI can be used).

Defining notifications

Notifications can be defined in Email notifications dialog, opened in the models list by selecting Notifications. The dialog contains a table of all notifications in the model, and notifications can be created, edited, deleted and sent. Defining notifications requires at least project Designer or project Administrator permissions (GenericWrite permission).

Each notification have following properties:

  • Name: Name for the notification describing and identifying the notification in the table of model's notifications.
  • To, Cc, Bcc: To, cc and bcc addresses for the email message recipients. At least one valid email address needs to be defined in any of these fields.
  • Subject: Subject of the email message.
  • Body: Body of the email message. The body can be defined as an html document, if the Body is html is checked.
  • Model filter: Model data is filtered using this filter, creating the dataset to be used for the notification calculation.
  • Measures: Measures are calculated for each of the dimension value (or the entire data, if no dimensions are defined). Measures can be used in the email fields and also in the Criteria expression.
  • Criteria: Optional expression that determines whether the email is sent or not. For example, this can be used to define a criteria that the notification is sent only if a measure is greater than the defined threshold value.
  • Body is html: When checked, the email body is an html document. If unchecked, the email body is plaintext.
  • Priority: Priority of the email message: High, Normal or Low.
  • From email address: Email address where the notification appears to be coming from. If there is a default from address defined for the system, this field can be left empty.
  • Sender:
  • Reply to address: One or several email addresses which appear as recipients when replying to the notification email.
  • Dimensions: Dimensions can be used the notification definition needs to send several emails to different recipients (for example, related to each region, product or customer). If no dimension is defined, only one notification email is sent.

To add dynamically changing content to the fields defining the email message (e.g. To, Cc, Bcc, Subject, Body), it's possible to use measure and dimensions names using syntax ${name}. It's also possible to define expressions inside the similar curly brackets.

Example for email subject (assuming there is a measure numberOfCases):

Process is blocked for total of ${numberOfCases} orders

Another example where there is an embedded expression using the ${...} syntax:

Process is blocked for total of ${Count(EventLog.Cases)} orders

Sending notifications

Notifications can be sent ("triggered") either in the Email notifications dialog by clicking the Send notifications button, or by using the Model.TriggerNotifications() function in the expression language. Note that actual emails might not necessarily be sent depending on the criteria defined by the notifications. Notifications can be triggered from the SQL scripts as follows (notifications Notification 1 and Notification 2 for model id 123):

(SELECT 'AnalysisType', '33') UNION ALL
(SELECT 'ContextType', 'Generic') UNION ALL
(SELECT 'Configuration', '{"Root":"ModelById(123).TriggerNotifications([""Notification 1"", ""Notification 2""])"}')
--#GetAnalysis