Use mail scripts in email notifications

  • Release version: Australia
  • Updated May 4, 2026
  • 1 minute to read
  • Add dynamic content and custom logic to email notifications using mail scripts.

    Before you begin

    Role required: admin

    About this task

    For more information on creating mail scripts, see Notification Email Scripts on the developer site.

    Procedure

    1. Navigate to All > System Notification > Email > Notification Email Scripts.
    2. Select New or open an existing mail script.
    3. Add the text for the message body into the script by using the template.print() function.
      .Sample JavaScript template
    4. Optional: Use event parameters in the script, such as event.parm1 and event.parm2, if the notification is triggered by an event.
    5. Save the mail script.
    6. Open the email notification or template where you want to use the mail script.
    7. To use an existing mail script, open the What it will contain tab and add the ${mail_script:script_name} embedded script to the Message HTML field.
      Replace script_name with the name of the mail script.
    8. To add a mail script inline, enter the script in the Message HTML field and enclose it within <mail_script> and </mail_script> tags.
    9. Save the record.
    10. In the confirmation dialog box, select Yes.
      The script is added to the Email Script [sys_script_email] table and replaced in the body with an embedded script tag: ${mail_script:mail script}.
    11. Optional: Apply HTML sanitization to help avoid security concerns in your HTML content by replacing ${mail_script:mail script} with ${{mail_script:mail_script}}.
      Confirm that HTML sanitizer is enabled.
      Note:
      For more information, see HTML Sanitizer.