Email Notifications: Difference between revisions

From QPR ProcessAnalyzer Wiki
Jump to navigation Jump to search
Line 15: Line 15:
* '''Subject''': Subject of the email message. Cannot be empty.
* '''Subject''': Subject of the email message. Cannot be empty.
* '''Body''': Body of the email message. The body can be defined as an html document, if the ''Message is html'' is checked.
* '''Body''': Body of the email message. The body can be defined as an html document, if the ''Message is html'' is checked.
* '''Model filter''': This filter is applied to the model data, creating the dataset to be used for the notification calculation.
* '''Model filter''': This filter is applied to the model data, creating the dataset to be used for the notification calculation. The filter can be used to narrow down the data related to which to send the notifications to.
* '''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.
* '''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 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.
* '''Criteria''': Expression that determines whether the email is sent or not. For example, the criteria can be used to define that the notification is sent only if a measure is greater than the defined threshold value. The criteria expression is optional, and if not defined, the notification is always sent.
* '''Message is html''': When checked, the email body is an html document. If unchecked, the email body contains plain text.
* '''Message is html''': When selected, the email body is interpreted as an html document. If unselected, the email body should contain plain text.
* '''Priority''': Priority of the email message: ''High'', ''Normal'' or ''Low''.
* '''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.
* '''From email address''': Email address where the notification appears to be coming from. If there is a default from address defined for the system ([[PA_Configuration_database_table_in_QPR_ProcessAnalyzer#SMTP_Server_Settings|SmtpFromAddress]]), this field can be left empty.
* '''Reply to address''': One or several email addresses which appear as recipients when replying to the notification email.
* '''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.
* '''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.

Revision as of 23:51, 20 February 2021

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 to be sent to several recipients with different message 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. 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, that can be opened in the models list by selecting Notifications. The dialog contains a table of all notifications in the model, and there notifications can be created, edited, deleted and sent. Defining notifications requires at least project Designer or project Administrator permissions (GenericWrite permission).

Notification rows can be double-clicked or selecting a row and clicking the Edit button, to open a dialog for editing an individual notification. Each notification have following properties:

  • Name: Name for the notification describing it shortly and identifying it in the model notifications list.
  • To, Cc, Bcc: List of to, cc and bcc recipient addresses for the email message. At least one email address needs to be defined in any of the fields. One address is mandatory.
  • Subject: Subject of the email message. Cannot be empty.
  • Body: Body of the email message. The body can be defined as an html document, if the Message is html is checked.
  • Model filter: This filter is applied to the model data, creating the dataset to be used for the notification calculation. The filter can be used to narrow down the data related to which to send the notifications to.
  • 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 in the criteria expression.
  • Criteria: Expression that determines whether the email is sent or not. For example, the criteria can be used to define that the notification is sent only if a measure is greater than the defined threshold value. The criteria expression is optional, and if not defined, the notification is always sent.
  • Message is html: When selected, the email body is interpreted as an html document. If unselected, the email body should contain plain text.
  • 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 (SmtpFromAddress), this field can be left empty.
  • 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 processed and 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 no actual emails might necessarily be sent if the the criteria for sending the emails is not fulfilled. Note also that triggering the notifications only starts the processing, so neither the Send notifications button nor the TriggerNotifications return any errors if the notification processing fails.

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

Use cases