Application management : Alerts : Working with Alerts : Creating a dynamic email subject using expressions
Creating a dynamic email subject using expressions
Procedure
In order to make an email's subject dynamic, you can use an expression in the Email subject field of the mail merge template that is linked to a notification definition. In the following example procedure, the internal tradespeople are to be notified of overdue orders. If the number of days an order is overdue is 10 at the moment of sending the notification, the email subject will reflect that, thanks to the expression. If, at another time or for a different tradesperson, the number of days the order is overdue is 5, the email subject will reflect that number.
1. In Alerts Management, at Alerts Notification definitions, create a notification definition with a code (01) and description (Overdue orders).
2. Make sure that the linked Alert condition includes a filter in which the Requested end date-time of the order is <&startofday.
* 
See the Alerts user documentation for information on creating and activating notification definitions.
3. Go to Service Manager.
4. Go to the Work orders selection level.
5. On the action panel select Report.
6. Create a mail-merge definition that includes the order fields Number and Requested end date-time.
7. In the mail-merge Settings pane, add an expression in the Email subject field.
* 
See the Report Manager user documentation for information on creating mail merge report definitions and mail merge templates.
This expression could be like the following example:
"Order " + Orders.Number + " is " + numToString(abs(extractDay(currentDate() ) -extractDay(Orders.'Requested completion date') )) + " days late."
The emails that are sent based on the above notification definition and report definition, will have a dynamic email subject: 'Order [OrderNumber] is [x] days late'. If no expression is used the email subject will consist of the Code and Description of the notification definition.