0

Make a Better Notification with System Properties and Mail Scripts 0 (0)

The article below is intended for any person customize their Notifications. A working Javascript and HTML is useful but not required.

Introduction

We often focus on getting job done and ready to be delivered. Of course this is important but sometimes we need more than just doing it. In the following article, we will look how to automate and centralize data in one place in order to become scalable and easier to find and edit. 

Here’s a few things we will cover:

Use CaseExample
Automate properties (sys_properties)System properties store configuration information that rarely or never changes. Each time you change or add a system property, the system flushes the cache to keep all nodes in the cluster in synch. This cache flush has a very high performance cost for one to 10 minutes, which can potentially cause an outage if done excessively. To prevent such outages, do not use a system property to store configuration information that changes more than once or twice a month. I usually update the “From” field.
Use email templates (sysevent_email_template)Enable administrators to create reusable content for the subject line and message body of email notifications.Usually I define a mail_script (to use a standard style for all notifications), define subject and message.

 

Use Case Walkthrough

Use Case #1: Automate properties

  1. In the Navigation filter, enter sys_properties.list.The entire list of properties in the System Properties [sys_properties] table appears.
  2. Verify that the property does not exist by searching for the property name.
  3. Click New.
    Usually I use “company.default.notification.from”.
  4. Complete the System Property form.
    Type: String
    Value: Community Article <email@service-now.com>
  5. Navigate to System Definition > Business Rules.
  6. Click New.
  7. Fill in the fields, as appropriate.
    Tab When to run
    When: Before
    On Insert (check)
    On Update (check)
    Tab Advanced
    current.from = gs.getProperty(“company.default.notification.from”);
    gs.addInfoMessage(‘Loaded company.default.notification.from value’);

Use Case #2: Create a Template and assign to the Notification

  1. Navigate to System Policy > Email > Templates.
  2. Click New.

Fill in the form fields (see table).

In the “Message HTML”, usually I call a default stylesheet just in case of I need to change any HTML tag (font, size, etc).

  • Add <p>${mail_script:notification_email.styles}</p>.

To use a mail script, 

  • Navigate to System Notification > Email > Notifications Email Scripts. 
  • Click New: “Notification_email.styles”
  • On the your email script:
    var stylesheet = new GlideRecord (‘sp_css’);
    stylesheet.get(‘name’,’company_email_notifications.css’); //Stylesheet for email styling
    template.print(‘<div><style>’ + stylesheet.css + ‘</style></div>’);

3. Navigate to System Notification > Email > Notifications.
4. Open the email notification record that should use the template.
5. Navigate to the What it will contain section.
6. From the Email template field, select the appropriate template.
7. Click Update.

Conclusion

System properties are not limited to just Notifications, they’re part of the NOW Platform and can include anything we have in the Platform. Try to automate your instance and try to centralize all your “customer” data in one place.

Use all the tools at your disposal to make that happen.