Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Notification scripts allow you to get email values or set them using the SimpleEmailOutbound class.
There are four objects available for creating a notification script:
Object | Class |
---|---|
current | SimpleRecord |
template | SimpleTemplatePrinter |
SimpleEmailOutbound | |
event | SimpleRecord |
To receive the values of the current and event objects, use dot-notation to address to the properties relating to the colunm names and the current and sys_event tables. See the example below:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
(function runNotificationScript(
/* SimpleRecord */ current,
/* SimpleTemplatePrinter */ template,
/* SimpleEmailOutbound */ email,
/* SimpleRecord */ event
) {
email.setSubject('Additional comments have been added');
email.setBody(`Additional comments:
${event.sys_created_by.display_name}: "${event.param_2}"`);
if (current.days_count > 3 && !current.requester.vip) {
email.addAddressCc(current.requester.email, current.requester.display_name);
}
})(current, template, email, event); |
You can use the same script in multiple email notifications and notification templates. To do so, add a Add a ${script:script_name}
embedded script tag to the notification rule or to the related notification template. The fields below are available for the script embedding:
- Subject
- Message
- Message (HTML)
- Other
To create a notification script, complete the steps below:
- Navigate to System Notification → Notification Scripts.
- Click New and fill in the fields.
- Click Save or Save and Exit to apply changes.
Note |
---|
To locate where notification scripts are used, perform a search against the version list. To do so, complete the steps below:
In step 3a, specify your script name after the "script:" declaration. For example, "script:stop_notifications". The selection example is given on the screenshot below. |