Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Notification Use the notification scripts allow you to get email values or set them using the SimpleEmailOutbound class. to dynamically change the parameters of the outgoing messages using the SimpleEmailOutbound class. 

You can use the same script in multiple email notifications and notification templates. To do so, add a ${script:script_name} embedded script tag to the notification rule or to the related notification template. You can use the embedded scripts in the following fields:

  • Subject
  • Message
  • Message (HTML)
  • Other

To create a notification script, complete the steps below:

  1. Navigate to System Notification → Notification Scripts.
  2. Click New and fill in the fields.
  3. Click Save or Save and exit to apply the changes.

Notification Script form fields

FieldMandatoryDescription
NameYA script name for later usage in notifications and templates. The name should not contain spaces.
ScriptY

Enter the script using SimpleOne server-side API, particularly, the SimpleRecord Server-Side, SimpleEmailOutbound and SimpleTemplatePrinter classes.

There are four objects available

for creating a notification script:

in the notification scripts:

  • current the SimpleRecord class object that triggered the notification.
  • template the SimpleTemplatePrinter class object.
  • email the SimpleEmailOutbound class object. 
  • event the SimpleRecord class object.
ObjectClasscurrentSimpleRecordtemplateSimpleTemplatePrinteremailSimpleEmailOutboundeventSimpleRecord

To receive the values of the current and event objects, use the dot-notation to address to the properties relating to the colunm column names and of the current andEvents (sys_event) tables. See the example below:

Code Block
languagejs
themeEclipse
titleExample
linenumberstrue
(function runNotificationScript(
    /* SimpleRecord */ current,
    /* SimpleTemplatePrinter */ template,
    /* SimpleEmailOutbound */ email,
    /* SimpleRecord */ event
    ) {

    email.setSubject('Additional comments havecurrent.number + '- additional comment has been added');
    email.setBody(`Additional`A comment commentsfrom:
    ${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 ${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:

    1. Navigate to System Notification → Notification Scripts.
    2. Click New and fill in the fields.
    3. Click Save or Save and Exit to apply changes.
    Note

    To locate where the notification scripts are used, perform a search against the version list. To do so, complete the steps belowfilter the records in the VCS Records (sys_vcs_record) table using the condition builder by the following conditions:

    1. Navigate to Configuration Pack → VCS Records.
    2. Click on the funnel icon  on the top to open the Condition Builder condition builder.
    3. Create a filter containing the conditions listed below:
      1. JSON Copy CONTAINS script:script_name
      2. Table Name IS NOT sys_notification_script
      3. Is Current IS Yes.

    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.

    Image Modified