Module 8: Notifications
Strategies for Testing Notifications
1. Preview the Notification 2. System Log > Emails 3. System Mailboxes > Outbound 4. Send a notification to your Inbox to see if you receive it 5. Send notifications to a test address using the Send all email to this test email address email property
Add CCs & BCCs
Add CCs and BCCs using the email global variable. Example: email.addAddress('cc', current.u_employee.manager.email + ' ');
Check Outbound Emails from the System Mailboxes
All menu to open System Mailboxes > Outbound
When can notifications be sent? More than one response may be correct. 1. Record is updated 2. Workflow Notification activity 3. The user has settings configured to receive notifications 4. Record is inserted 5. A user right-clicks a record and selects the Send notification menu item
Answer: 1,2,3,4
Notification Email Scripts print Notification message content from a server-side script. Which of the following objects is NOT available to Notification Email Scripts? 1. current 2. schedule 3. template 4. email 5. event
Answer: 2 Schedule. There is no schedule object for Notification Email Scripts.
Which of the following are ways to specify a notification recipient? More than one response may be correct. Hard-coded email address Select a ServiceNow user Select a ServiceNow Group Pass the recipient in parm2 Send to the event creator
Answer: All of them are correct
What one of the following is the correct syntax for adding dynamic content to a notification's HTML message field? 1. {current.short_description} 2. $current.short_description 3. ${current.short_description} 4. {short_description} 5. ${short_description}
Answer: The correct response is 5. Dynamic content is enclosed in ${}. The fields are assumed to be fields on the current object.
Which of the following are sections in a notification record? More than one response may be correct. How to send When to send Why to send Who will receive What to send
Answer: When to Send, Who will Receive, What to Send
Script Value Override
Any value set in a script overrides the settings in the notification configuration. For example, if a script uses the email.setSubject() method, the method overrides the value set in the notification's Subject field.
Create Channel (User Notification Preferences)
Click Create Channel to add an email address, mobile device, or SMS. The configuration fields change depending on the Type field.
Force Delivery Field
DEVELOPER TIP: To force a notification to be sent even if recipients have unsubscribed, developers can modify the Notification form layout to include the Force delivery field. When selected, notifications are sent regardless of user notification preference settings.
True or False? Adding a user to a notification's Who will receive section means the user will receive the notification.
False. Users can manage their notification preferences including disabling notifications.
Outbound Email
In order to send and receive email on your Personal Developer Instance, outbound email needs to be configured. System Diagnostics > Email Diagnostics. Email sending is disabled by default in Personal Developer Instances.
Creating Inbound Email Actions
Inbound Email actions are an application file and are created in Studio.
Inbound Email Actions
Inbound email actions define what actions ServiceNow takes in response to incoming email. 1. The first step is to determine if the message is a reply, forward, or new message. ServiceNow searches the subject line of the incoming message for prefixes indicating reply or forward. To set the prefixes, use the All menu to open System Mailboxes > Administration > Email Properties. 2. If an inbound message is recognized as a reply or forward ServiceNow attempts to match the incoming email with an existing record by looking for a unique watermark in the subject line or message body. By default, watermarks are inserted as the last line of outbound messages. 3. The final step to determine which Inbound Action executes is to check the conditions for a match. Use the Condition builder to create the condition or write a Condition script.
Using a Notification Email Script in a Message
Include a Notification Email script in a notification Message HTML field using this syntax: ${mail_script:scriptName}
Link Syntax
Links in messages to make it easy for users to access records in ServiceNow or to unsubscribe from notifications. URI: Link to the current record. The link text is LINK. URI_REF: Link to the current record. The link text is the display value for the record. <reference_field_name>.URI: Link to a record determined by dot-walking. Link text is Link. <reference_field_name>.URI_REF: Link to a record determined by dot-walking. Link text is the display value for the related record. NOTIF_UNSUB: Link to unsubscribe from notifications. Link text is Unsubscribe. NOTIF_UNSUB+link_text="<value to insert as link text>": Link to unsubscribe from notifications. Link text is specified by the notification developer. NOTIF_PREFS: Link to the user's Notification preferences. Link text is Notification Preferences. NOTIF_PREFS+link_text="<value to insert as link text>": Link to the user's Notification preferences. Link text is specified by the notification developer.
Inbound Email
Mail sent from any user into ServiceNow
Change Email Sender Name
Modify the Email user label field in the ServiceNow SMTP Email account using the System Mailboxes > Administration > Email Accounts module.
Notification Email Scripts
Notification Email Scripts print Notification message content from a server-side script. Note: Although Notification Email Scripts are application files, they must be created in the main ServiceNow browser window and not in Studio. System Notification > Email > Notification Email Scripts Notification Email Scripts have access to: current (GlideRecord API) email (GlideEmailOutbound API) template (TemplatePrinter API) event (only for notifications responding to events)
Create Notification
Notifications are Application Files, so they are created in Studio. Three Sections to configure in a Notification 1. When to Send 2. Who will receive 3. What it will contain
Who Will Receive
Notifications can be sent to specific users and groups or to user/groups in fields on the record that generated the notification. The Who will receive section defines the recipient(s) for a notification. Recipients can be static or determined dynamically. Adding a user to a notification's Who will receive section does not guarantee the user will receive the notification. The user record has settings related to notifications.
Notifications
Notifications send outbound email to one or more recipients in response to specific activities in ServiceNow. Notifications can be sent when: -Records are inserted or updated -Events are generated -The Notification activity executes in a workflow -The Send Email action executes in a flow
Weight
Priority; When multiple Notifications are simultaneously triggered for the same record and addressed to the same recipient(s), the Weight field value determines which notification(s) to send and which to skip. Notifications with a Weight value of zero are always sent. If notifications have non-zero Weight values, only the notification with the highest Weight value is sent. If multiple notifications have the same non-zero Weight value and that value is the highest, all notifications with that value are sent.
Identifying the Sender (Inbound Email)
ServiceNow parses the sender of the inbound email into the email.from property and attempts to match the email address to a record in the User [sys_user] table. If a match is found: -ServiceNow impersonates the user when taking action in response to the email. -Scripts have access to the user's information through the GlideSystem methods such as gs.getUserName(). If no match is found: -If automatic User creation is enabled, Users are created automatically and then impersonated. -If automatic User creation is disabled, the user Guest is impersonated.
Notification Security
ServiceNow sends notifications to all recipients in the Who will receive section, even if those users are NOT authorized to view the record. If the record contains sensitive or protected data, consider restricting the recipient list to just those users and groups who normally have access to it, and do not enable the Subscribable option.
Dynamic Content
The Subject, SMS Alternate, and Message HTML fields can use dynamic content. Use the Select variables column to easily construct the dynamic syntax for fields from the record associated with the notification. To dynamically reference a field value from the record that triggered the Notification, enclose the field name in ${ }: ${<field_name>}. Use dot-walking to reference field values on related records: ${<field name containing related record>.<field name>}. To reference the event parameters parm1 or parm2, use this syntax: ${event.parm1} or ${event.parm2}. (Only for notifications fired by events.)
What it will contain
The What it will contain section specifies the notification contents and envelope information. The Message HTML field can include server-side scripts.
When to Send
The When to Send section defines the conditions required to send the notification. The available configuration fields depend on whether the notification is sent when a record is inserted or updated or in response to an event.
Watermark
The watermark is one of the strategies used to match the inbound email to the outbound email for a record.
Testing Notifications (Outbound Email Configuration)
To test all notifications in a non-production instance, add an email address to the "Send all email to this test email address" Email Property. To test individual notifications, add a test address to the notification, as seen in the Exercise: Create Notification.
Create Personal Notification (User Notification Preferences)
Users can click the Create Personal Notification link to subscribe to a notification that does not include their user in the Who will receive Users list.
User Notification Preferences
Users can: 1. Enable/disable notifications 2. Add a new channel (email address, mobile device for push notifications, SMS, voice) 3. Disable receipt of specific notifications 4. Subscribe to subscribable notifications to receive notifications the user would not ordinarily receive 5. Apply a schedule to a notification
Advanced Condition
Uses a server-side script to evaluate conditions that cannot be created using the Condition field. The script has access to two global variables: current: The target table record associated with the notification (All notifications). event: The event object that triggered the notification (only available for notifications sent when Event is fired).
Parsing Inbound Email
When email is received, ServiceNow parses the email and populates the properties on the global email variable. See notes for properties