Notifications
Notifications
Notifications
ServiceNow
PDF generated using the open source mwlib toolkit. See http://code.pediapress.com/ for more information.
PDF generated at: Tue, 18 Jul 2017 05:30:40 PST
1
Introduction
System Mailboxes
Overview
Sent and received email can be seen in the System Mailboxes application, where you can view the Inbox, Outbox,
and Sent mailboxes. Each provides a filtered view of emails to let you see only what you need to at any given time,
including list fields applicable to each. From the left navigation pane, select System Mailboxes > Status to see your
current POP and SMTP status.
The System Mailbox is hosted by ServiceNow, who have sole access to the mailboxes. By default, once the
ServiceNow application has pulled an email message, it will be deleted from the mail server and stored in the
application on the sys_email table.
Mail Delivery
Inbound emails: All inbound mail is placed into the Inbox until it is processed. After it is cleared, the email moves
to the Received state. If the ServiceNow system is restarted for any reason (such as during a system upgrade), all
inbound mail waits on the external mail server until ServiceNow can request delivery.
Outbound emails: All outbound mail is placed into the Outbox until it is processed. Once cleared, it is moved to
Sent (if sent) or Skipped (not sent, as in the case of no valid recipients). If the ServiceNow system is restarted for
any reason (such as during a system upgrade), all outbound mail waits in the ServiceNow database until
ServiceNow comes online, and the scheduler looks for mail to deliver.
Notifications 2
Notifications
Overview
Notifications are important communication tools that keep users informed of events that concern them. You can use
email and SMS notifications to send and receive communication from within the system. Notifications are triggered
by system events, but unlike business rules, require no scripting knowledge. You can send notifications to email
addresses and SMS devices, such as cell phones. Notifications can also be forced to override any user preferences or
settings. This ensures the correct users always receive important notifications.
Users can subscribe to notifications of interest or unsubscribe from notifications that they do not want with the
subscription based notifications feature.
The subscription based notifications feature enables users to subscribe to notifications of interest or unsubscribe
from notifications that they do not want . This feature also enables administrators to send mandatory notifications
that users cannot block. A separate interface enables you to select the devices and service providers for SMS
notifications.
Email Notifications
For email messages, an administrator writes a simple form email that is sent out every time a certain event occurs.
The Email Notification form uses variables to return field values from the table generating the notification. For
example, an email notification generated by an incident can contain information about who opened the incident, the
incident's priority, and the description.
Users can enable or disable the email notifications for themselves. They can also define more specific rules
regarding which email notifications to receive if subscription based notifications are active. Users who receive email
notifications can respond to the email, which triggers an inbound email action. Inbound email actions are the other
half of the communication functionality that email notifications provide. By responding to email notifications, users
can interact with the system through their email provider, without logging in to the instance.
SMS Notifications
Short messaging service (SMS) is the standard protocol used to deliver short text messages to cell phones. Most cell
phones support SMS, even if they do not support more sophisticated messaging like email. ServiceNow can deliver
alerts and notifications to SMS devices in addition to delivering standard email notifications. This is particularly
useful when critical events require immediate attention and an email notification may be too slow.
SMS messages, unlike emails, are limited to extremely short text strings, 140 characters in most cases. To
compensate for this limitation, subscription based notifications provide the SMS alternate field for the Email
Template and Email Notifications forms. Administrators can use this field to enter brief messages for SMS
notifications.
ServiceNow sends SMS messages through an SMTP gateway to the cell phone companies. The carriers then forward
the information to the devices. If the cell phone provider has an SMTP gateway, it can send SMS messages.
To configure notifications for SMS devices, such as cell phones, perform the following tasks.
Note: Your instance can send SMS messages if your carrier provides an SMTP to SMS gateway service. Verify this with your
carrier.
Notifications 4
Social IT Notifications
Social IT table notifications generate automatic live feed messages or chat messages. When a record is inserted or
updated on a specific table and the notification conditions are met, a live feed or chat message is generated. Live
feed messages can be posted to the company feed or to any group. Chat messages are posted to the chat room that is
associated with the record.
To learn more, see Setting Up Live Feed Table Notifications.
Enhancements
Fuji
The Email Properties page provides SMS Sender job diagnostics.
The system provides better handling of emails with excessively large bodies. Improvements include error logging
and the prevention of truncated emails triggering inbound email actions. Additionally, the
glide.email.outbound.max_body_bytes property is added and enables administrators to configure the
maximum outbound email body size.
The system stores calendar data from incoming email as an attachment on the associated record by default. The
glide.email.inbound.calendar_behavior property enables administrators to modify how the system
stores calendar data.
The glide.email.outbound.header.auto_submitted property determines whether to add an
"Auto-submitted" header to all outbound emails.
The glide.email.reply_subject_prefix property recognizes additional reply subject prefixes for
meeting invitation responses.
Notifications 5
Eureka
Properties are available to limit the number and total size of email attachments allowed per email (Eureka Patch
4).
Email notifications created in Eureka are in a rich HTML format.
Administrators have the option of converting individual existing email notifications to the rich HTML format.
Images can be inserted into email notifications with an image picker in the WYSIWYG editor.
Images linked with URLs relative to a particular instance are converted to absolute URLs, preventing broken
links.
Mail scripts are condensed into a single, easy-to-read line that can be reused in multiple email notifications.
A Newlines to HTML check box has been added to the Email Script form to help ensure backward compatibility
with older scripts.
Properties are available for controlling the conditions by which recipient notifications are logged.
Administrators can filter device notifications using a schedule.
Dublin
The Mail Properties page layout has changed.
The Mail Diagnostics section provides information about the current state of your email configuration.
A system property, glide.smtp.encryption, in the Outgoing Mail Server section of the Mail Properties
page has been added to replace the glide.smtp.secure and glide.smtp.tls properties for specifying
how to encrypt communications with the SMTP server.
The following system properties are private to prevent their values from being copied to new instances during
clone requests or as part of update sets: glide.email.override.url, glide.email.user,
glide.pop3.secure, and glide.smtp.auth.
6
Configuration
Configuration Options
ServiceNow offers the following email configuration options.
Standard email configuration
Standard email configuration using your own address or domain
Alternate email configuration using your own SMTP server
Alternate email configuration using your own POP3 server
Alternate email configuration using your own SMTP and POP3 servers
Note: When the email accounts plugin is active, the system does not use the email properties. Configure account settings through the
Email Accounts module.
Note: Instances do not support the processing of incoming email messages with a signed certificate. The body of the email is stripped
out because the instance cannot process the part of the email that is stored in plain text or HTML.
Configuring Email Properties 7
Note: ServiceNow automatically adds the necessary system property settings when provisioning your instance. You should not need
to change any settings to enable email, but these settings are provided as a reference.
Outgoing glide.email.user SMTP account (e.g. [email protected]). Username Email address of the instance. For example,
Mail Server is before the '@' when SMTP authentication is enabled [email protected].
glide.email.user User email (eg. [email protected]) that is used to log in Email address of the instance. For example,
to the SMTP server optionally. [email protected].
Configuring Email Properties 8
Note: This configuration requires changing your internal email architecture to forward email from your custom email address to
your instance's actual email address. ServiceNow also recommends implementing a spam filter on your custom email address to
prevent unwanted mail from triggering actions on your instance.
Outgoing Mail glide.email.user SMTP account (e.g. Custom email address you want to use in place of the
Server [email protected]). Username is instance email address. For example,
before the '@' when SMTP authentication [email protected]. This address becomes the
is enabled instance's reply-to address.
Outbound Mail glide.email.username Outgoing mail display name (e.g. "Help The display name of the custom email address. For
Configuration Desk") example, Help Desk.
Configuring Email Properties 9
glide.email.user User email (eg. [email protected]) Custom email address you want to use in place of the instance email
that is used to login to the SMTP server address. For example, [email protected]. This address
optionally. becomes the instance's reply-to address.
glide.email.username Outgoing email display name (e.g. "Help The display name of the custom email address. For example, Help Desk.
Desk")
Outgoing Mail glide.email.server SMTP mail server URL to your SMTP server. For example,
Server smtp.yourdomain.com.
Outgoing Mail glide.smtp.auth SMTP server requires username and password Select Yes if your SMTP server requires
Server authentication authentication.
Outgoing Mail glide.email.user SMTP account (e.g. [email protected]). Email address to use for both SMTP
Server Username is before the '@' when SMTP authentication and the reply to address. For
authentication is enabled example, [email protected].
Outgoing Mail glide.email.user_password SMTP account password Password for your SMTP server.
Server
Outbound Mail glide.email.username Outgoing mail display name (e.g. "Help Desk") Display name for the SMTP email address. For
Configuration example, SMTP.
Configuring Email Properties 11
glide.email.server Outgoing (SMTP) mail server. URL to your SMTP server. For example, smtp.yourdomain.com.
glide.email.user User email (eg. [email protected]) that Email address to use for both SMTP authentication and the reply to
is used to login to the SMTP server optionally. address. For example, [email protected].
glide.email.mail_to [None] [Optional] Email address to use for the reply to address if different
from the SMTP authentication address. For example,
[email protected].
glide.email.username Outgoing email display name (e.g. "Help Display name for the SMTP email address. For example, SMTP.
Desk")
glide.email.user_password Outgoing (SMTP) mail server password. Password for your SMTP server.
glide.smtp.auth Authenticate with the SMTP server using the Select Yes if your SMTP server requires authentication.
user name and password properties
Configuring Email Properties 12
Incoming Mail glide.pop3.server POP3 mail server URL to your POP3 server. For example, pop.yourdomain.com.
Server
Incoming Mail glide.pop3.user POP3 account Email address to use for POP authentication. For example,
Server [email protected].
Incoming Mail glide.pop3.password POP3 account Password for the POP3 server.
Server password
Configuring Email Properties 13
glide.pop3.server Incoming (POP) mail server, if different from outgoing URL to your POP3 server. For example,
(SMTP) mail server pop.yourdomain.com.
glide.pop3.user Incoming (POP) mail account name, if different from Email address to use for POP authentication. For example,
outgoing (SMTP) mail account name [email protected].
glide.pop3.password Incoming (POP) mail account password, if different from Password for the POP3 server.
outgoing (SMTP) mail account password
Alternate Email Configuration Using Your Own SMTP and POP3 Servers
This alternate email configuration uses both internal SMTP and POP3 servers.
1. Navigate to System Properties >
Email.
2. Configure the following email properties
and click Save.
3. Verify you receive a Connection
Successful message for the Outgoing
Mail Server.
Alternate Email Configuration Using Your Own Custom SMTP and POP3 Servers
Configuring Email Properties 14
Outgoing Mail glide.email.server SMTP mail server URL to your SMTP server. For example,
Server smtp.yourdomain.com.
Outgoing Mail glide.smtp.auth SMTP server requires username and password Select Yes if your SMTP server requires
Server authentication authentication.
Outgoing Mail glide.email.user SMTP account (e.g. [email protected]). Email address to use for both SMTP
Server Username is before the '@' when SMTP authentication and the reply to address. For
authentication is enabled example, [email protected].
Outgoing Mail glide.email.user_password SMTP account password Password for your SMTP server.
Server
Outbound Mail glide.email.username Outgoing mail display name (e.g. "Help Display name for the SMTP email address. For
Configuration Desk") example, SMTP.
Incoming Mail glide.pop3.server POP3 mail server URL to your POP3 server. For example,
Server pop.yourdomain.com.
Incoming Mail glide.pop3.user POP3 account Email address to use for POP authentication. For
Server example, [email protected].
Incoming Mail glide.pop3.password POP3 account password Password for the POP3 server.
Server
glide.email.server Outgoing (SMTP) mail server. URL to your SMTP server. For example, smtp.yourdomain.com.
glide.email.user User email (eg. [email protected]) that Email address to use for both SMTP authentication and the reply to
is used to login to the SMTP server optionally. address. For example, [email protected].
glide.email.mail_to [None] [Optional] Email address to use for the reply to address if different
from the SMTP authentication address. For example,
[email protected].
glide.email.username Outgoing email display name (e.g. "Help Display name for the SMTP email address. For example, Help
Desk") Desk.
glide.email.user_password Outgoing (SMTP) mail server password. Password for your SMTP server.
glide.smtp.auth Authenticate with the SMTP server using the Select Yes if your SMTP server requires authentication.
user name and password properties
glide.pop3.server Incoming (POP) mail server, if different from URL to your POP3 server. For example, pop.yourdomain.com.
outgoing (SMTP) mail server
glide.pop3.user Incoming (POP) mail account name, if different Email address to use for POP authentication. For example,
from outgoing (SMTP) mail account name [email protected].
glide.pop3.password Incoming (POP) mail account password, if Password for the POP3 server.
different from outgoing (SMTP) mail account
password
Note: Even if the email and its attachments are less than 25MB, the actual size of an email message could be larger when it gets
encoded by an email client. So these messages might exceed the limit when they reach the instance.
Next Steps
After enabling email on your instance, you may want to complete these related tasks.
Test the email configuration by routing all email to a single user (set the glide.email.test.user
property).
Review the baseline email notifications to determine if they meet your business needs.
Review the baseline inbound email actions to determine if they meet your business needs.
Determine if you want to create users when ServiceNow receives an email from an unrecognized user.
Determine what kind of watermarks outbound email uses to associate records with email messages.
Set the precedence of outgoing mail. By default, ServiceNow sends email with a precedence of "bulk" (set the
glide.smtp.precedence_bulk property).
Consider preventing untrusted users from triggering inbound actions. This is one way of preventing unwanted
email from affecting your instance.
Implement a spam filter to restrict unwanted messages sent to your custom email addresses.
Enhancements
Dublin
Email service is now available during upgrades. See Email Service Availability.
The email properties page has a new layout.
Calgary
The default SMTP server changed to relay.
A new property glide.email.mail_to specifies the email address to use as the reply to address in links
included in email notifications. This property allows customers to use distinct email addresses for SMTP
authentication and notifications.
A new property glide.email.smtp.max_recipients specifies the maximum number of recipients a
notification can have before ServiceNow splits the notification into multiple messages. By default, ServiceNow
splits a notification with more than 100 recipients into multiple messages with each message having up to 100
recipients.
References
[1] https:/ / community. servicenow. com/ community/ service-automation-platform/ notifications/ blog/ 2015/ 01/ 28/
whitelisting-emails-sent-from-servicenow-own-email-infrastructure
Enabling the Email Client 17
Note: This capability is not inherited by tables that extend the current table. For example, enabling the email client on the Task table
does not enable it for the Incident or Problem tables.
Enabling the Email Client 18
Note: The Subject field on the email client allows a larger character count than the default setting for the Subject field on the Email
table. If the subject text from the client is being truncated, increase the Max length value for the Subject field on the Email table. See
Modifying Dictionary Entries for instructions.
Note: Make sure that your users have their notification device configured in their user settings.
Toolbar
Use the controls in the toolbar to send the email, attach files, insert quick message text, or check spelling.
Note: The email client only displays the Quick Message selector if you have already created quick message records.
Keyboard Shortcuts
The following keyboard shortcuts can be used:
Alt+S: Send email
Email client autocomplete
HTML Support
The email client always uses the multipart/mixed content type and supports HTML markup in the message body.
See Email Notifications for more information.
Note: Line breaks do not appear for multi-line fields such as ${description} and ${comments} in the email client template.
ACL access Defaults to allowing only users with the itil role to access the email client. Change the To control who can see the email
ACL rule to control access to the email client. client: Controlling Access to the
Email Client
Email icon Allows only users with write access to the current table to see the email icon. To remove the email icon:
Removing the Email Icon
Autocomplete Defaults to only displaying a user's first and last name. A system property controls what To change search behavior:
columns the email client autocomplete displays. If your organization has several users with Configuring Email Client
the same name, consider adding company or email address columns to help distinguish Autocomplete Search Results
between users. To display additional information:
Displaying Additional Information
in the Email Client Autocomplete
From Defaults to hiding the field. A system property can display the field on the email client. To display the field: Displaying an
The From setting defaults to the values in the User email (glide.email.user) and Editable From Field
Outgoing email display name (glide.email.username) system properties. To edit the default value: Creating
Email Client Templates
Reply to Defaults to hiding the field. A system property can display the field on the email client. To display the field Displaying the
The Reply to field defaults to the values in the User email (glide.email.user) and Reply To Field
Outgoing email display name (glide.email.username) system properties. To edit the default value: Creating
Email Client Templates
To Defaults to the email address of the caller. To edit the default value: Creating
Email Client Templates
Cc Defaults to the email addresses of the user who opened the incident and all users in the To edit the default value: Creating
watch_list. Email Client Templates
Subject Defaults to the incident number and short description. To edit the default value: Creating
Email Client Templates
Enabling the Email Client 20
Note: Because the visibility of the email icon is determined by whether the current user has write access to the table, it is possible
that a user may be able to see the email icon and still not open the email client.
Note: If the Client Templates module is not visible, enable the module.
Field Description
Table Select the table that the template applies to. You must enable the email client for the same table.
Note: The list shows only tables and database views that are in the same scope as the template (starting with the Fuji
release).
To Enter a comma-separated list of either field names that contain user email addresses or specific email addresses.
Cc Enter a comma-separated list of either field names that contain user email addresses or specific email addresses.
Bcc Enter a comma-separated list of either field names that contain user email addresses or specific email addresses.
Subject Enter a description of the email. The description can contain a comma-separated list of field names or specific values.
Body Enter any text or mail script that you want to appear in the message body.
Here is a sample template for the Incident table that you can use in a mail script:
template.print("Incident number -" + current.number + "\n");
Here is how the template populates an incident email.
Enabling the Email Client 21
Property Description
Property Description
glide.ui.email_client.email_address.disambiguator Sets the columns from the User [sys_user] table that the autocomplete
list displays. Separate each column name with a semicolon character (;).
See the system dictionary for a list of available column names. For
example, to add the sys_user.email and sys_user.company columns, set
the property to: email;company.
Type: string
Default value: name
Location: Add to the System Property [sys_properties] table
Property Description
glide.email_client.show_sms_option Specify whether a check box appears in the email client for sending the message to the user's
SMS device. If no SMS device exists, the email client sends the message to the primary email
device.
Enabling the Email Client 22
Quick Messages
Quick messages allow you to insert predefined text into the message body of the email client. Selecting a quick
message fills the Message Text field with the body specified in the quick message. After you define one or more
quick messages, the Quick Message selector appears in the email client. You can reference variables directly in
quick messages. Use the following syntax: ${variable_name}.
Note: If you add attachments to the Quick Message templates, the attachments are not sent as part of the email distribution.
Field Description
Active Select this check box to make the quick message available for selection. Clear this check box to remove the message from the Quick
Message selector.
User Select the user who has access to this quick message. Selecting a user restricts access to that user only. Leave the field blank to have no
user-based restrictions.
Group Select the group whose members have access to this quick message. Selecting a group restricts access to members of that group only. Leave
the field blank to have no group-based restrictions.
Body Enter the text you want to insert into the Message Text field. By default, the field supports HTML format.
Business Rules
A business rule is a piece of JavaScript that you can configure to run when a record is inserted, updated, or deleted,
or as part of a table query. All business rules run either before or after the database action has occurred. Event-based
notifications add event records to the event queue using the following script logic.
If [something is true], then [add a specific event to the queue]
For more information, see Creating a Business Rule.
Events and Email Notification 25
Building a Script
The incident events business rule comes with the system and defines a number of events that can be triggered by
different actions in the Incident table.
This business rule defines several events, three of which are triggered after a record in the Incident table is inserted
or updated. The first script is:
The condition in this script requires that a change be made to the Comments field in an existing (not inserted)
incident record. If this condition is true, then ServiceNow adds the incident.commented event to the event queue.
The second condition requires that a record be inserted before the event is added to the queue.
if (current.operation() =='insert') {
The third condition is true whenever the incident record is updated (including updates to the Comments field, as
specified by the first script).
if (current.operation() == 'update')
The then part of each script, the gs.eventQueue function, adds the event to the event queue. This statement uses
the following syntax, set off with braces:
Record The record referenced when the condition in the script evaluates to true. Usually this is expressed as current, meaning the current record
the business rule is working on. If the business rule is being triggered as part of a scheduled job, use a GlideRecord argument in its place.
Parm1 Passes a string value. Notification events pass the Sys ID of the user with the gs.getUserID() method. Other scripts can reference
this string value as parm1 using the format ${event.parm1}.
Parm2 Passes a string value. Notification events pass the user name with the gs.getUserName() method. Other scripts can reference this
string values as parm2 using the format ${event.parm2}.
Event States
Events may exist in one of several states:
Events and Email Notification 27
State Description
Ready The system created the event and it is in the queue waiting to be processed.
Processed The event successfully ran. An event does not necessarily trigger any further action when processed. Additional functionality must
make use of the event.
Error The event encountered an error during processing. This state is often caused by invalid event parameters. Reprocessing the event may
resolve the error.
Transferred The event was rotated to a different shard of the Event [sysevent] table. When an event is rotated, a duplicate record is created in an
active shard to be processed. A scheduled job processes the event when it is next in the queue, but it is not possible to predict when
this will happen as because several events may need to be processed before it. Therefore, you can reprocess the event.
Reprocessing Events
To reprocess an event:
1. Navigate to System Logs > Events.
2. Open an event.
3. Under Related Links, click Reprocess Event.
The event returns to the event queue.
Global Events
ServiceNow has a global function called global_events() that triggers from a business rule when these
conditions occur:
Inserting new records
Updating existing records
Adding comments to an existing record
Assigning a record to a user
Exceeding a record's inactive timer
For example, if you add the script global.events(current) to a business rule on the change_request table,
ServiceNow automatically configures the following events:
change_request.inserted
change_request.updated
change_request.commented
change_ request.assigned
change_ request.inactive
The business rule for global events on the change_request table looks like this:
Events and Email Notification 28
if (current.operation() == 'insert') {
gs.eventQueue("change.inserted", current, gs.getUserID(),
gs.getUserName());
}
if (current.operation() == 'update') {
gs.eventQueue("change.updated", current, gs.getUserID(),
gs.getUserName());
}
if (current.start_date.changes() || current.end_date.changes() ||
current.assigned_to.changes()) {
if (!current.start_date.nil() && !current.end_date.nil() &&
!current.assigned_to.nil()) {
gs.eventQueue("change.calendar.notify", current,
current.assigned_to, previous.assigned_to);
}
gs.eventQueue("change.calendar.notify.remove", current,
current.assigned_to, previous.assigned_to);
}
Events and Email Notification 29
}
// Remove old calendar from current assigned to, due to date changing
else if (!current.assigned_to.nil()) {
if ((current.start_date.changes() && !previous.start_date.nil())
||
(current.end_date.changes() && !previous.end_date.nil())) {
gs.eventQueue("change.calendar.notify.remove", current,
current.assigned_to, current.assigned_to);
}
}
}
30
Setup
Email Notifications
Overview
Use email notifications to send selected users email about specific activities in the system, such as updates to
incidents or change requests. If you want to change how the system processes incoming email, see Inbound Email
Actions.
Email notifications allow administrators to specify:
When to send the notification
Who receives the notification
What content is in the notification
Additional email notification options are available. Users can subscribe to notifications, and administrators can make
some notifications mandatory. See Notifications for all the tasks required to create and send custom email when
system events occur.
Administrators also have the option of converting existing email notifications to a rich HTML format (starting with
the Eureka release). This format provides several advantages, including :
Raw HTML content is converted into a WYSIWYG format.
The content can be edited in a feature-rich HTML editor.
Mail scripts are condensed into a single, easy-to-read line that can be reused in multiple email notifications.
To prevent broken links, items like images and incidents, that are linked with URLs relative to a particular
instance are converted to absolute links. For example, if an incident is linked using a relative URL, the link is
converted to an absolute link.
Note: The rich HTML format is the default for all new email notifications starting with the Eureka release.
Field Description
Name Enter a unique name for the email notification. Descriptive names help identify the purpose of the email notification. For example,
Incident Opened & Unassigned.
Table Select the database table to which this notification is linked, such as Incident [incident].
Warning: Do not select the Task [task] table. This table is for extending other tables. Notifications that run on the
Task table directly are not supported.
Note: The list shows only tables and database views that are in the same scope as the email notification (starting with
the Fuji release).
Type Select the type of notification you are creating: EMAIL or Meeting Invitation.
Note: If multiple notifications are generated by the same trigger, the system only sends on notification. The system considers all other
notifications, even those with a different subject and body, as duplicates. This functionality is controlled by the Ignore Duplicates
business rule.
When creating a notification based on a new or updated record, specify what additional conditions must be met to
trigger the notification. You can specify these notification-specific conditions.
Changes: Checks to a see if a field value changes.
Changes from: Checks to see if a field value changes from a particular value.
Changes to: Checks to see if a field changes to a particular value.
Use these steps to specify when to send a notification.
1. Identify the notification.
2. Fill in the fields for the When to send section of the Email
Incident notification sent on insert or update
Notifications form (see table).
Field Description
Send when Select under what condition the notification is sent: when a record is inserted or updated or when a particular event is triggered.
Weight [Required] Set a numerical value for this notification's priority relative to other notifications with the same target table and recipients.
The system only sends the notification with the highest weight. All other notifications are moved from the Outbox to the Skipped
mailbox. The default value 0 causes the system to always send the notification (assuming the conditions are met).
For example, suppose a service desk agent adds a comment to an incident and shortly thereafter closes it. By default, these actions
trigger both the Incident commented and Incident Closed notifications. However, since both notifications are from the Incident table
and both notify the incident caller, the system only sends the notification with the highest weight, in this case the Incident Closed
notification.
Notification weights
Note: The SMTP Sender scheduled job determines how often to send email. By default, this job runs every minute.
Conditions Use the condition builder to select the conditions under which this notification is sent. For example, you might select Priority >
greater than > 3 - Moderate to send the notification only for High and Critical priority incidents.
Inserted Select the check box to enable email notification when a record is inserted. This field is visible only when the Send when field has
been set to Record inserted or updated.
Email Notifications 33
Updated Select the check box to enable email notification when a record is updated. This field is visible only when the Send when field has
been set to Record inserted or updated.
Event Select the event that triggers this notification. This field is visible only when the Send when field has been set to Event is fired.
name
You can add a script-based condition in the Advanced condition field by configuring the Email Notification form
and adding the field. You can access the field in the Advanced view without configuring the form starting with the
Eureka release.
The advanced condition script uses the following global variables:
current: contains the current record from the table to which the notification is linked.
event: contains the event that triggered the notification.
Note: The Advanced condition field is evaluated in addition to other conditions you set on the notification. Both the Condition and
Advanced condition must evaluate to true in order to send the notification.
Email Notifications 34
Field Description
Users/groups in Select users or groups from reference fields and Glide lists of the notification record's table. For example, if a notification uses the
fields Incident [incident] table, then you can select users or groups from incident fields like Opened by and Assignment group. This
list of users or groups is variable and depends upon the values of the associated task record.
Note: You can dot-walk to values in reference fields by clicking the plus sign in the field selector and then selecting the related
field.
Users Select the users you want to receive the email notification. You can search for users with the reference lookup icon or manually
add their email addresses. This list of users is static.
Groups Select the groups you want to receive the email notification. You can search for groups with the reference lookup icon or by
manually entering the group name. This list of groups is static.
Note: As a best practice, use the same format type for all notifications. This ensures that all notifications have a consistent look and
feel.
Although there are no required content elements, you can use one or more of the following options to specify the
email notification contents:
Attach documents from source records
Customize the watermark
Format the email body using an email template
Add and edit HTML markup
Add images
Specify alternative outbound email addresses
Note: Additional fields are available in Advanced view; however, these are needed only under rare circumstances.
Email Notifications 36
Fill in these fields to specify the content of an email notification (starting with the Eureka release).
Field Description
Email If you want to re-use existing content, select an email template to add content to the email notification.
template
Subject Enter the subject line for the email message. The subject can include variables from the Select variables column.
Message Enter the content of the email notification message. The message can include variables from the Select variables column. Variables
HTML map to column names available from the notification table, its parent tables, and reference tables. Use variables to include values from
a record in the table such as an incident's short description or comments and work notes. The Message HTML field is visible only if
you set the content type to HTML and plain text or HTML only.
Note: If you want to include a link to the record that triggered the notification, see Enabling Links to ServiceNow Records.
SMS Enter the notification message to send to an SMS device. The SMS alternate message is limited to 140 characters.
alternate
Enter values for the following fields on the legacy Email Notification form.
Email Notifications 37
Field Description
Email If you want to re-use existing content, select an email template to add content to the email notification.
template
Subject Enter the subject line for the email message. The subject can include variables from the Select variables column.
Message Enter the content of the email message. The message can include variables from the Select variables column as well as HTML code
if you set the content type to HTML and plain text. Variables map to column names available from the notification table, its parent
tables, and reference tables. Use variables to include values from a record in the table such as an incident's short description or
comments and work notes. Notes:
You cannot use HTML code to control the appearance of the contents of the ${comments} variable.
If you want to include a link to the record that triggered the notification, see Enabling Links to ServiceNow Records (Deep
Linking).
SMS Enter the notification message to send to an SMS device. The SMS alternate message is limited is 140 characters.
alternate
Note: The letter "P" at the bottom of the screen shows the location of your cursor within the Message field. In this case, the cursor is
in a line containing an HTML <p> tag.
Note: For email notifications that were created in the Eureka release or that were already converted, the Switch to Rich HTML
Editor button is not displayed.
Email Notifications 39
In many cases, an unconverted mail script fails to run from inside the HTML editor. If you select Yes, the script is
added to the Email Script [sys_script_email] table and is automatically replaced in the body with an embedded script
tag.
You can view the mail scripts in their original form by opening the email notification and clicking the Show
Notification Scripts related link.
Selecting the Newlines to HTML check box indicates that the method for handling line breaks in earlier versions
carries forward for email notifications and templates used in Eureka. When an email notification or template is
converted to rich HTML, the Newlines to HTML check box is automatically selected.
For new mail scripts written in Eureka, it is a best practice to add correct HTML line breaks to
template.print() statements.
If an email notification or template to rich HTML is not converted to rich HTML, newlines are automatically
wrapped with <div> tags, the same as versions prior to Eureka. The old mail scripts still work; however, the
administrator does not enjoy the benefits of working in the rich HTML format, and does not have as much control
over exact HTML formatting.
Best Practice
When writing new scripts, it is best to insert explicit HTML line breaks and clear the Newlines to HTML check box
so that no HTML tags are injected when email notifications are generated. The same approach is recommended for
existing notifications and templates. That is, a best practice would be to replace template.print("\n")
JavaScript function calls with template.print("<br />"). This gives you better control over the HTML
formatting of your email notifications.
Adding HTML Markup When the email format is multipart/mixed, you can add HTML markup to the body of the message. For example, this
HTML markup:
Linking to an Attachment
You can add attachments to a notification by linking to the attachment record in the message of the notification.
Linking to attachment records in this fashion requires using email notification scripting. For example:
template.print('Attachment: <a href="/sys_attachment.do?sys_id=' + gr.sys_id + '">' + gr.file_name + '</a>\n');
${report:X:Y}
where:
X is the type of report you want to attach (reportID, gaugeID, dashboardID, or chartID).
Y is the sys ID of the report, gauge, dashboard, or chart to be attached.
For example:
${report:reportID:<abc123>}
${report:gaugeID:<abc123>}
${report:dashboardID:<abc123>}
${report:chartID:<abc123>}
Email Notifications 43
${URI+&sysparm_scriptlet=current.assigned_to=gs.getUserID()
&sysparm_scriptlet_condition=current.assigned_to.nil()
&sysparm_view=incident_active}
current.assigned_to=gs.getUserID()
current.assigned_to.nil()
Related Record to Provide Link to Notification record table Reference Field Samples
Related task record to be approved from an approval Approval Approval for ${sysapproval.URI}
notification [sysapproval_approver] [sysapproval] ${sysapproval.URI_REF}
For example, the following notification template produces the email links in the picture below:
${CMS_URI+<site>/<page>}
For example, to link the email recipient to a page called Incident in the content site ESS, with the current incident as
the target document, use the following format:
${CMS_URI+ess/incident_detail}
The resulting email URL has this format:
https://<instance
name>.service-now.com/ess/incident_detail.do?sysparm_document_key=incident,46e18c0fa9
Note:
Create a custom watermark prefix for each instance to prevent accidentally triggering events in the wrong instance.
Do not use colons (:) in custom watermark prefixes. Colons are a reserved character and may cause the watermark to be ignored.
Email clients that use the plain text version of the email still show the watermark.
Email Notifications 45
4. Click Update.
Email Notifications 46
Send to event Select this check box to send the notification to the person who performed the action that started the notification process if the
creator person is also specified in the Users/groups in fields, Users, or Groups field. If the event creator is not specified in one of
these fields, the event creator does not receive a notification regardless of the setting in this field.
[2]
For troubleshooting information, see Troubleshooting email notifications - Send to the Event Creator on the ServiceNow
Community.
Event parm 1 Select this check box if the event parameter 1 contains one or more email recipients (in a comma separated list). This field is
contains recipient visible only when the Send when field is set to Event is fired.
Event parm 2 Select this check box if the event parameter 2 contains one or more email recipients (in a comma separated list). This field is
contains recipient visible only when the Send when field is set to Event is fired.
Subscribable Select this check box to allow users to subscribe to this notification.
Warning: Do not select this check box for any other type of notification. See Subscribable Notifications
for details.
Content type Select the content type for the email notification:
HTML and plain text
HTML only
Plain text only
By default, HTML only is enabled.
Include Select this check box to send all attachments from the triggering record as email attachments.
attachments
Omit watermark Use this check box to apply or remove the watermark attached to each email. ServiceNow does not recommend removing the
watermark as a reply to an email without a watermark creates a new incident rather than updating the incident the original email
referred to. For more information, and an alternative way to hide watermarks, see Watermarks.
Email Notifications 48
Message Text Enter the notification message to send in plain text. This field is visible only if you set the content type to HTML and plain
text or Plain text only.
From Enter the email address you want the email notification to use in the From field. For example, [email protected].
Reply to Enter the email address you want people to use when replying to the email notification. For example,
[email protected].
[3]
Warning: Before you activate the Engine Based Notifications plugin, see KB0540612 to prevent the loss of customizations.
If you have the admin role, use the following steps to activate the plugin.
1. Navigate to System Definition > Plugins.
2. Right-click the plugin name on the list and select Activate/Upgrade.
If the plugin depends on other plugins, these plugins are listed along with their activation status.
3. [Optional] If available, select the Load demo data check box.
Some plugins include demo datasample records that are designed to illustrate plugin features for common use cases. Loading demo data is
a good policy when you first activate the plugin on a development or test instance. You can load demo data after the plugin is activated by
repeating this process and selecting the check box.
4. Click Activate.
References
[1] https:/ / hi. service-now. com/ kb_view. do?sysparm_article=KB0535129
[2] https:/ / community. servicenow. com/ community/ service-management/ incident/ blog/ 2015/ 02/ 04/ beware-beware-the-event-creator
[3] https:/ / hi. service-now. com/ kb_view. do?sysparm_article& #61;KB0540612
Email Templates 49
Email Templates
Overview
Email templates enable administrators to create reusable content for the subject line and message body of email
notifications. Templates deliver consistent information on specific system activities and improve the efficiency of
creating multiple email notifications for similar actions. If necessary, you can make minor changes on the fly to an
email that uses a template by overriding the subject line and message body content in the notification form. A
common practice is to define the message body in a template and create new subject lines for different types of
recipients. There is no limit to the number of templates that you can create.
Email templates are created in rich HTML format, and administrators have the option of converting existing email
templates to rich HTML (starting with the Eureka release). This format provides several advantages, including:
Raw HTML content is converted into a WYSIWYG format.
The content can be edited in a feature-rich HTML editor.
Mail scripts are condensed into a single, easy-to-read line that can be reused in multiple email notifications.
To prevent broken links, images linked using URLs relative to a particular instance are converted to absolute
links.
Creating a Template
This section provides instructions for creating a template with rich HTML formatting, which is available starting
with the Eureka release. If you are using an earlier version, see the previous version information.
1. Navigate to System Policy > Email > Templates.
2. Click New.
3. Fill in the fields, as appropriate (see table).
Email Templates 50
Field Description
Name Enter a unique name for the template. For example, change.update.risk.
Table Select the name of the table involved. For example, Change Request [change_request].
Subject Enter a subject line that explains the purpose of the email. Select the appropriate variables for the subject line from the fields available on
the selected table. Place the cursor where you want the variable to appear, and click the field name in the Select variables column. For
example:
SMS Create a different message to be delivered to the recipient's SMS device. You might want a brief message, showing the most important
alternate information only. If this message field is blank, the contents of the Message Text field are used for the SMS message.
Note: The message in this field is used when the message is sent to a device configured as SMS.
Message: Construct a message that includes all the information you think the recipients need to know. Select
the appropriate variables for your message from the fields available from your selected table. Place the cursor
where you want the variable to appear, and click the field name from the Select variables column. The special
character, <hr/>, creates a manual break in the message that sets off the Comments section. For example, we
can create a message using the following variables:
Short Description: ${short_description}
Click here to view request: ${URI}
Priority ${priority}
<hr/>
Work Notes:
${work_notes}
Note: You can construct the message using HTML, or add individual HTML tags to change the font or color
of the text, including the contents of the variables. The only exception to this is the appearance of the contents
of the ${comments} variable, which cannot be controlled by HTML.
SMS alternate: Create a different message to be delivered to your SMS device. You might want a brief
message, showing the most important information only. If this message field is blank, the contents of the
Message field are used for the SMS message.
The template should look like this:
4. To apply the template, select it in the Email template field of an email notification record.
Email Templates 52
5. To override a template value, enter a new value for the field you want to override. For example, you might
change the subject line to read The risk level of ${sys_class_name} ${number} has been raised to ${risk}. This
would not change the basic information about the change request contained in the template, but would make the
email notification appropriate for the change manager who needs to know when risk levels are escalated above a
certain threshold.
Note: Use HTML tags to format the email body for readability. For example, you can use <br/> to insert a line break, or you can
wrap paragraphs in <p> ... </p> tags to format paragraph text.
4. Modify the message text, as needed, using the WYSIWYG editor or by editing the underlying HTML.
Note: The letter "P" at the bottom of the screen shows the location of your cursor within the Message field. In this case, the cursor is
in a line containing an HTML <p> tag.
Note: Email templates that are already formatted with rich HTML do not show the Switch to Rich HTML Editor button.
Calendar Integration
With email notifications, you can use import export maps to leverage information about records and integrate with
Outlook or another calendar. For example, an email notification can create a calendar event based on the planned
start and end dates of a change request. To integrate with a calendar, add one or more of the following iCalendar [1]
variables to an email template message and reference the email template from the notification. The variables must be
added to the Message Text field starting with the Eureka release.
Email Templates 54
${description} Description
${location} Location
Note: In order for the calendar integration to work, iCalendar variables must be added to an email template. The integration does
not work if the variables are added directly to the email notification.
By default, the ServiceNow system computes the value of iCalendar variables using import export maps for the
following tables:
Appointment [itil_appointment]
Change Request [change_request]
Incident [incident]
Reminder [reminder]
Each import export map can specify a different set of iCalendar fields.
For example, the icalendar.change_request import export map only
maps two iCalendar fields.
Import export maps
ServiceNow uses the External Name as the variable name in the email
template. For example, the icalendar.change_request import export
map defines the dtstart and dtend variables.
Sample mappings for the dtstart and dtend
variables
External Name Associated Variable Name Table Field Mapped Field Label
Note: Mail script is not allowed or processed in meeting invitation email templates.
BEGIN:VCALENDAR
PRODID:-//Service-now.com//Outlook 11.0 MIMEDIR//EN
VERSION:2.0
METHOD:REQUEST
BEGIN:VEVENT
ATTENDEE;ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:${to}
DTSTART:${dtstart}
DTEND:${dtend}
UID:${sys_id}
DTSTAMP:${dtstamp}
DESCRIPTION:${description}
SUMMARY:${u_meeting_summary}
END:VEVENT
END:VCALENDAR
Click the plus to view details about each line of the iCalendar invitation template.
Email Templates 57
BEGIN:VCALENDAR Yes
VERSION:2.0 Yes
METHOD:REQUEST Yes
BEGIN:VEVENT Yes
ATTENDEE;ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:${to} Yes
DTSTART:${dtstart} Yes You must use the import export map to map dtstart
to a start time field on the custom table.
DTEND:${dtend} Yes You must use the import export map to map dtend to
an end time field on the custom table.
UID:${sys_id} Yes You must provide the name of a field that uniquely
identifies the record, such as the sys_id or the record
number field.
DTSTAMP:${dtstamp} Yes
END:VEVENT Yes
END:VCALENDAR Yes
Troubleshooting
For more information about troubleshooting email templates, see the following posts in the ServiceNow community:
Div tags messing with your email client templates? [2]
Extra line spacing with paragraph tags in email client [3]
References
[1] http:/ / en. wikipedia. org/ wiki/ ICalendar
[2] https:/ / community. servicenow. com/ community/ blogs/ blog/ 2014/ 12/ 05/ email-client-template-script-not-working
[3] https:/ / community. servicenow. com/ community/ blogs/ blog/ 2014/ 12/ 12/ extra-line-spacing-with-p-tags-in-email-client
Notification Examples
Overview
The following examples illustrate the process of composing email and SMS messages for ServiceNow notifications.
The two processes are identical, with the exception of the length and content of the message. SMS messages do not
permit user response to links and are limited to 140 characters. Use the SMS alternate field in the Email Template
and Email Notification forms to create a brief text message for SMS devices.
The examples on this page are:
Example 1: Simple Reminder
Example 2: Approval Request Notification
Example 3: Priority 1 Incident Update Notification
Note: Be sure to register your new event. If you do not, the system will not know to look for it.
Create a notification
Now create an email notification record that reacts to the new incident.reminder event. This brief notification
message is suitable for SMS as well.
Note: This is a very simple reminder. There is no condition in place to delete or reschedule the reminder event if the incident is
deleted or if the date and time in the Reminder field is changed. The business rule, as presented, will schedule a new event every time
the Reminder field is updated. Nothing is configured to display a reminder that is currently scheduled for an incident. However, this
reminder is very simple and can be set up in just a few minutes.
5. Click Submit.
<font face="Courier">
current.u_assigned_to.changes()
</font face="Courier">
<font face="Courier">
gs.eventQueue("to_do.assigned", current, gs.getUserID(),
gs.getUserName());
</font face="Courier">
Notification Examples 62
7. Click Submit.
8. Test that the business rule is creating the event as follows:
a. Change the value in the Assigned to field of an existing To Do record or create a new record and specify an
Assigned to.
b. Navigate to System Policy > Event Log and look for an event with the name to_do.assigned.
c. To make this easier, you can sort the event log in descending order by created.
7. Click Submit.
Warning: Do not use your own POP server for this exercise. You should have a test account set up on your mail server (see the
administrator of your mail system). It may download the contents of your POP account. You may choose to skip configuring
Glide to use an email server and just check the Glide email log instead of sending an actual email (see final step below).
4. Click Save.
5. Test the assignment notifications.
a. Assign some To Do records.
b. Navigate to System Logs > Email to see that status of generated emails.
If you managed to configure your mail settings correctly, you should receive email notifications in a few
moments.
The change.itil.approve.role template called from the notification looks like this:
Notification Examples 65
The combination of the notification and template generates an email that looks something like the following:
Notice that the receiver of this email has the following links in the mail:
A link to view the approval record
A link to view all the details of the change request
A link that will generate an automatic email response to approve the change
A link that will generate an automatic email response to reject the change
Name Give your notification record a unique name, such as Incident of Priority 1 Updated.
User Click the magnifying glass icon and select a recipient from the list of ServiceNow users. You can select only one user in this field.
Event name Select the event to use for this notification. The incident.updated event is triggered by any change to an incident record and can be
used to send our notification.
User field Enter the field name from the Incident table that defines the recipient for this notification. For example, you might send notification
of an update to the person who opened the incident by typing opened_by.
Email Leave this field blank. We will cover the construction and use of templates in another exercise.
template
Group Click the magnifying glass icon, and then select a group from the list of ServiceNow groups. You can select only one group in this
field.
Table Select the appropriate database table, in this case Incident [incident].
Group field Enter the field name from the Incident table that defines the group to notify. For example, you might send notification of the update
to the designated assignment group by typing assignment_group.
Weight Weight determines the sending priority of each notification when more than one qualifies. This is an arbitrary scale that you set.
Send to Select this check box to send the notification to the person who performed the action that started the notification process if the person
event is also specified in the Users/groups in fields, Users, or Groups field. If the event creator is not specified in one of these fields, the
creator event creator does not receive a notification regardless of the setting in this field.
Conditions Updated --> is anything. This creates the condition under which the notification is sent. In our example, an update to any field in an
incident record sends an email to all recipients.
Subject Type an appropriate subject line for your email. Select variables for your content from fields in the Incident table. Put the cursor in
the subject line where you want the variable to appear, and then click the field name in the Select variables column. For this
exercise, type the following subject line and insert the variable for the Priority field: An Incident of Priority ${priority} has been
updated.
In this notification, the variable ${priority} returns the value 1 Critical.
Message Construct a message that includes all the information you think the recipients need to know about the updated incident. Select the
appropriate variables for your message from the fields in the Incident table. Put the cursor in the message where you want the
variable to appear, and then click the field name in the Select variables column. The special character, <hr/>, creates a manual
break in the message that sets off the Comments section. For this example, we create the following message:
List Click the lock icon to open a list of recipients for the email notification. Click the magnifying glass icon and select names from the
list of ServiceNow users. You can select as many users from the list as you want.
List field Enter the field name from the Incident table that identifies a list that contains potential recipients. For example, to send the
notification to users who are on the watch list for this issue, type watch_list.
SMS Enter an abbreviated version of the email message that eliminates such things as the ${URI} link that requires recipient interaction
alternate and the ${comments} field. SMS messages can only display 140 characters.
Subscribing to Notifications
How It Works
The notification system has two parts: the standard recipient-based notifications, and subscription based
notifications.
Subscription-Based Notification
Subscription-based notification enables users with the appropriate role to subscribe to notifications that are marked
as Subscribable and configure conditions and schedules for those notifications. When a notification is subscribable,
the system sends the message to users who have subscribed to that notification. The system checks the user's
notification preference for any filter and schedule settings relevant to the message. If the preferences permit delivery,
the system sends the notification to the device specified (email or cell phone).
The following is an example of a subscription-based notification.
Jerrod Bennett calls the service desk again, and the service desk employee creates another incident.
The service desk employee adds a comment to the incident. This triggers a custom subscribable notification called
Incident commented by San Diego service desk employees, which the San Diego service desk manager uses to
monitor quality.
The system sends the following notifications:
Jerrod receives the Incident opened for me notification message because he is the incident Caller.
The San Diego service desk manager receives the Incident commented by San Diego service desk
employees notification message because he has subscribed to it.
Subscription Based Notifications Plugin 70
Note: Subscription preference information is stored on the Notification Message [cmn_notif_message] table.
Getting Started
To set up and use subscription based notifications for email and SMS notifications, complete the following tasks.
References
[1] https:/ / hi. service-now. com/ kb_view. do?sysparm_article=KB0538135
Unsubscribe from notifications: To unsubscribe from a notification, click the toggle to the off position. Users
cannot unsubscribe from a mandatory (locked) notification when they access this form.
The following shows notification preferences prior to the Fuji release.
You can perform the same tasks as you can for the Fuji release, with these exceptions or differences:
Add or remove notifications: Click a red X to remove the notification from that user. Notifications that were sent to you or that are mandatory
are marked with a gray X and cannot be removed.
Unsubscribe from notifications: To unsubscribe from a notification, click the Off button.
Related Lists
To enable Related Lists for subscription-based notifications, you must configure the User form and your task forms.
Note: If you are using Notification Preferences from Related Links to manage notifications, this step is not necessary.
To use Related Lists for subscription-based notifications, add the Notification Devices and Notification Messages
lists to your user form.
Adding an
Unsubscribe Link to an
Email Message
You can add an Unsubscribe link to
the bottom of any email body by
A locked notification that cannot be turned off or deleted
pasting in the following text. Be sure
to change the values in arrow brackets
to suit your environment. For instructions on creating email messages, see Email Notifications and Email Templates.
<mail_script>
</mail_script>
This opens the Notification Service Provider record from the Notification Service Provider table.
Advanced Removes all the previous options and displays the Advanced script field.
notification
Advanced Used for custom notifications that run a script rather than construct a traditional SMS/email. This is generally used when all
script outbound SMS messages must run through a central SMS hub, as opposed to being sent directly from the ServiceNow instance to
the SMS provider. Advanced users can construct a script in this field that will send a notification to an old style numeric pager that
cannot receive SMS communications. This field is rarely used and employs advanced scripts. See Advanced Notification Scripts
for examples of what you can use in the script.
Construct Removes the prefix and suffix options and displays the Construction script field
address
manually
Construction Allows you to script the email address construction as you would in a business rule. For example, abc + current.phone_number +
script [email protected] would construct an email address of [email protected]. NOTE: Current is a reference to the device,
not the service provider, hence the current.phone_number variable that uses the device's phone_number value.
SMS Provider Places the provided text before the device's specified phone number (e.g. [email protected]).
Email Prefix
SMS Provider Places the provided text after '@' sign (e.g. 2223334444@SUFFIX)
Email suffix
Notification Additional, optional attributes of an SMS device used inside an SMS service provider's Advanced script. This is generally used
Device to deliver SMS notifications to an internal SMS distribution technology. This is an advanced scripting procedure and is not
Variables necessary for configuring external SMS providers.
email.class
email.sysId
email.textBody
email.hashCode
email.weight
email.equals
email.logEmail
email.reset
email.wait
email.body
email.SMSText
email.watermark
email.textBodyLegacy
email.sourceHeader
email.subject
email.instance
email.importance
device.service_provider
device.group
device.order
device.sys_id
device.sys_updated_by
device.sys_created_by
device.primary_email
device.schedule
device.name
device.sys_created_on
device.email_address
device.active
device.phone_number
device.sys_mod_count
device.sys_updated_on
device.user
device.sys_meta
device.type
Setting Up Subscription Based Notifications 76
Notification Filters
Notification filters enable a user to control the delivery of messages by creating special conditions on multiple tables
in a single, reusable filter. For example, you can create a filter that controls message delivery when active incidents,
problems, and change requests for network issues reach a critical state. Notification filters are available for selection
in the Filter field of a user's Notification Preferences form.
Note: The system applies the user's filter conditions after the administrator's conditions have been evaluated. If the administrator's
conditions fail, the system ignores notification filters.
3. Repeat the procedure to create additional conditions on other tables for this filter.
Using Subscription Based Notifications 77
Managing Notifications
Subscription-based notifications can be managed by adding notification devices, subscribing to and unsubscribing
from messages, and setting the filters and schedules that control how and when messages are delivered.
Note: Notification devices such as cell phones and pagers must be able to receive SMS notifications. To receive email notifications
on an old style, numeric pager, you must construct an advanced script in the service provider record.
4. Click Submit.
Your new device is listed below
your primary email device and is
ready to configure.
Field Description
Phone number Enter the phone number to which SMS notifications should be sent.
This field is available if you selected SMS or Voice in the Type field.
Email address Enter the email address to which the notifications should be sent.
This field is available if you selected Email in the Type field.
User Enter the name of the user who should receive notifications. By default, this shows the name of the user configuring the device.
Order Enter a number to determine where the device appears in the list. The lower the number, the higher it appears in the list.
Note: Filters that you apply to messages do not override the original filters that the administrator created for the notifications. Your
filter conditions are evaluated after the original conditions are met. If the administrator's notification filter fails, your filter conditions
are not evaluated. If neither an advanced filter nor a predefined filter is selected, you see all notifications that match the
administrator's original filter conditions.
Field Description
Notification Select a message from the list. Related fields appear for certain notifications. For example, if you select CI affected or Location
Message affected, a field appears for selecting the CI or the location. Duplicate messages are not permitted on a device.
Device Select the notification device for the message. The device that you are adding a notification for is selected by default, but you can
change the device, if appropriate.
Filter Select a notification filter to refine the notifications that you receive. For example, you might select a filter whose conditions send
notifications when an incident with a priority of 1 - Critical is opened for a network issue. The system evaluates the conditions in
this filter after the conditions in the administrator's notification filter. This field is not available when an advanced filter is
configured.
Using Subscription Based Notifications 80
Advanced Select the check box to enable the condition builder and select the table to use. When you select the check box, the Filter field is
filter replaced by the Table and Conditions fields.
Table Select the table for the notification. For example, if you select the CI affected notification message, you might select the Incident
[incident] or Change Request [change_request] table. This field appears when you check the Advanced filter check box.
Note: You might need to personalize the form to see all the fields below.
Inbound Email Actions 82
Field Description
Target Select the table where the action will add or update records.
table
Type Select the message type required to run the action. The action runs only if the inbound email is of the selected type. Available types
are:
New: An email that is not recognized as a reply or forward.
Reply: An email with a watermark with an In-Reply-To email header, or whose subject line begins with a recognized reply prefix.
Forward: An email whose subject line begins with a recognized forward prefix, even if the email also contains a watermark or
In-Reply-To header.
Note: By default, inbound emails of the Forward type always generate new incidents regardless of the presence of a
watermark. If this behavior does not match your business logic, you can change the recognized reply and forward prefixes to
treat forwards like replies.
Condition [Optional] Enter a statement that determines when the inbound email action runs. If a condition is entered, the action runs only when
the condition statement evaluates to true. For example:
email.subject.startsWith("chg:")
Active Select this check box to enable the action. Clear the check box to disable the action.
From [Optional] Select the user required to run the action. If a user is selected, the action runs only when the email sender matches the user
name. Leave this field blank to perform the action for all users.
Script Enter the script the action runs. Typically, this script uses the validators script include and email variables.
Description Enter a detailed explanation of what this inbound email action does.
Other fields
Order Enter a number to define the order in which this email action should be processed. Actions with lower numbers are processed first. For
more information, see Ordered Email Processing. This field is not installed by the Ordered Email Processing plugin.
Forward The email contains the following conditions: Create Incident Create new
1. A subject starting with a recognized forward prefix (even if a watermark or an (Forwarded) record
In-Reply-To header is present).
2. From <user email> appears anywhere in the email body.
Reply The email contains one of the following conditions and the table specified in the Update Incident (BP) Update
email matches the table of the inbound action: existing record
1. A valid watermark that matches an existing record.
2. An In-Reply-To email header (when no watermark is present) that matches an
existing record.
3. A subject line starting with a recognized reply prefix (when neither a watermark
nor an In-Reply-To header is present) and a valid record number that matches
an existing record.
New The email does not meet the conditions for either a reply or forward type inbound Create Incident Create new
email action record
If more than one inbound action is available for a particular type, ServiceNow uses the Table field to match the
email to a particular table. If there is also more than one action for the inbound action's table, ServiceNow uses the
Order field to determine the order in which the actions run.
Property Description
Property Description
glide.email.reply_subject_prefix re:,aw:,r:,fw:,fwd:
This causes all forwarded and replied to mail to be processed by the Update Incident inbound action.
The glide.email.forward_subject_prefix property must contain some text in order for the forwarded
email to be processed as a Reply. It can be any text except a forward prefix (that is, fw:,fwd:).
Note: Some versions of Microsoft Exchange Server require a hotfix to support the "In-Reply-To" header when replying to email that
originates from outside the organization.
Inbound Email Actions 85
Ref:MSG0000008 ServiceNow recognizes this as a watermark and searches the Email Watermarks [sys_watermarks] table for a record
with the number MSG0000008. If this watermark exists, ServiceNow matches the email to the associated record. If this
watermark does not exist, ServiceNow uses the inbound action for new emails to create a new incident, and associates
the new incident with the email.
Ref:MSGWTR0000008 ServiceNow recognizes this as a watermark and searches the Email Watermarks [sys_watermarks] table for a record
with the number MSGWTR0000008. If this watermark exists, ServiceNow matches the email to the associated record.
If this watermark does not exist, ServiceNow uses the inbound action for new emails to create a new incident, and
associates the new incident with the email.
Ref:WTR0000008 ServiceNow recognizes this as a watermark and searches the Email Watermarks [sys_watermarks] table for a record
with the number WTR0000008. If this watermark exists, ServiceNow matches the email to the associated record. If this
watermark does not exist, ServiceNow uses the inbound action for new emails to create a new incident, and associates
the new incident with the email.
MSG0000008 ServiceNow does not recognize this as a watermark because it does not start with the Ref: prefix. It uses the inbound
action for new emails to create a new incident, and associates the new incident with the email.
RE: Example ServiceNow recognizes this subject line as a reply and recognizes the INC prefix as belonging to the incident table.
INC0005574 ServiceNow searches the incident table for an existing record INC0005574. If this incident exists, the email is associated with
this incident. If this incident record does not exist, ServiceNow uses the inbound action for new emails to create a new
incident, and associates the new incident with the email.
RE: Example The instance recognizes this subject line as a reply but does recognizes the "INC prefix as belonging to the Incident table
"INC0005574" because of the quotation mark. The same error occurs for any character other than a space before the record number. The
RE: Example instance instead uses the inbound action for new emails to create an incident, and associates the new incident with the email.
*INC0005574
RE: "Example The instance recognizes this subject line as a reply and recognizes the INC prefix as belonging to the Incident table. The
INC0005574" instance searches the Incident table for an existing record INC0005574", which it will not find because of the quotation mark.
RE: Example The same error occurs for any character other than a space at the end of the record number. The instance instead uses the
INC0005574* inbound action for new emails to create an incident, and associates the new incident with the email.
RE: CHG0008593 ServiceNow recognizes this subject line as a reply and recognizes one, but not both, of the number prefixes. There is no way
and INC000576 to predict which prefix ServiceNow will match first. Whichever prefix it matches, it searches the corresponding table for a
matching record. If the record exists, the email is associated with the table. If the record does not exist, ServiceNow uses the
inbound action for new emails to create a new incident and associates the new incident with the email.
Note: ServiceNow does not support processing email with multiple numbers in the subject line because there is no way to
predict which record ServiceNow will match first. For this reason, ServiceNow does not recommend creating notifications
that include more than one $number variable.
FW: Example ServiceNow recognizes this subject line as a forward because of the FW: prefix and uses the inbound action for forwarded
INC0005574 emails to create a new incident, and associates the new incident with the email.
Example ServiceNow recognizes this subject as a new email because it does not contain a matching reply or forward prefix. It uses the
INC0005574 inbound action for new emails to create a new incident, and associates the new incident with the email.
Inbound Email Actions 86
Note: This functionality requires that you activate the Email Automatic User Creation plugin. For more information on the plugin,
see Upgrading the User Creation Method to Use the Full Email Address.
Inbound Email Action scripts no longer support the gs.createUser() method. Use either the automatically-generated
email variables or the gs.GetUserID() method instead.
Note: If inbound email comes from an untrusted domain, the instance impersonates the Guest user unless you explicitly prevent users
from untrusted domains from triggering inbound actions.
4. Click Save.
Note: When the property glide.pop3readerjob.create_caller is set to false, ServiceNow runs inbound actions from
users who do not match an existing user by impersonating the Guest user. You may want to prevent untrusted users from triggering
inbound actions by locking out the Guest user.
Upgrading the User Creation Method to Use the Full Email Address
You can upgrade the method ServiceNow uses to create users by activating the Email Automatic User Creation
plugin. The plugin makes the following changes:
Sets the property glide.email.create_userid_from_email to true.
Increases the width of the User ID [sys_user.user_name] column to accommodate email addresses.
After activating the plugin, enable automatic user creation from email.
Warning: ServiceNow, Inc. strongly recommends reviewing your existing user records to reconcile any that contain identical
email addresses. If you activate the plugin prior to reconciling email addresses, your instance cannot distinguish between users
with identical email addresses and will randomly select one of the users with the matching email address.
Variable Contents
email.to Contains a comma-separated list of email addresses in the To: and Cc: boxes.
email.from Contains an email address according to the following conditions. If the address listed in the email Headers field matches an
existing user's Email address, this variable contains the user's Email address. If the address listed in the email Headers
field does not match an existing user's Email address, this variable contains the address listed in the email Headers field
(starting with Eureka Patch 5) or the Guest user's Email address (in versions prior to Eureka Patch 5).
Inbound Email Actions 88
email.from_sys_id Contains the Sys ID of the user who sent the email to the instance.
email.origemail Contains the email sender's address as listed in the email Headers.
email.content_type Contains the MIME content type of the email (for example, text/plain; charset="us-ascii" or text/html;
charset="us-ascii").
email.headers Contains details about the sender, route, and receiver as a plain text string in the format of the sending email client.
[1]
Note: ServiceNow follows RFC 2822 (Internet Message Format), which requires multiple email addresses in a group to be
separated by commas, not semicolons. ServiceNow can set the values of the email.to, email.direct, and email.copied
variables only if email addressed to groups follow the expected RFC format.
Note: The action always generates a lowercase variable name. Note also that this functionality does not work on reference fields.
Foo:bar
The inbound email script creates the variable email.body.foo with the value of bar. You can use these variables to
create conditions such as:
if(email.body.foo != undefined) {
current.[field] = email.body.foo;
}
Inbound Email Actions 89
In this example, the script sets the value of [field] to the value bar.
Warning: You should have a unique email addresses for each user record. Otherwise, the instance can not reliably match the
email to the correct user and unpredictable matches may occur.
If providing a unique email address to each user is not possible, ServiceNow recommends only having one active
user with the shared email address. This configuration guarantees that ServiceNow always matches incoming email
from this address to the active user.
Notice the line in the template that shows Priority:${sysapproval.priority}. When replying to this
email, the approver can change the value of the Priority field directly from the email. For example, the approver
could set the priority to 4 Low:
Priority:4
Inbound Email Actions 90
Update the email address, original recipient, and assignment group name accordingly.
Attachments
If an inbound email contains one or more email attachments, the inbound email action adds the attachments to the
first record the action produces.
Character Encoding
ServiceNow checks the MIME type of incoming email to verify the character encoding. If the email encoding is
ASCII-7 or UTF-8, inbound email actions preserve the character encoding in any associated task records they
produce. If the email encoding is ISO-8859-1, the inbound email action attempts to convert the email to Windows
1252. Inbound email actions convert any other encodings (for example, Mac OS Roman) to plain text, which may or
may not be readable.
Property Value
Name com.glide.email.max_body_bytes
Description Specify the maximum size of an email message body in bytes. The size cannot exceed the default value of 16MB.
Type Integer
Value 16777216
Note: Email attachments have separate size limits. For more information, see Email Attachment Limits.
Warning: Allowing locked out users to trigger inbound actions also allows untrusted users to trigger inbound actions.
Warning: Enabling this feature also enables users from untrusted domains to trigger inbound actions.
Property Description
Inbound Email Actions 92
glide.pop3.process_locked_out Enables (true) or disables (false) the ability for locked out users to trigger inbound actions.
Type: true | false
Default value: false
Location: Add to the System Properties [sys_properties] table
Using sys_email
You can use the global variable sys_email with inbound email actions. This lets you access the received
sys_email record that triggered the inbound email action. It can be used to reference fields on the email record, such
as uid, sys_id, content_type, and so on.
Troubleshooting
The following solution to this common inbound email error is useful for troubleshooting email actions. For more
information, open the ServiceNow Knowledge Base and access the following two articles:
For troubleshooting inbound email, see KB0524472 [2].
For troubleshooting outbound email, see KB0521382 [3].
Email from Outlook produces an Configure the local Outlook client or Exchange server to not send Rich Text formatted (RTF) data to
empty Incident record containing an ServiceNow instances. To prevent Windows email from containing a winmail.dat file, see Microsoft KB
attachment named winmail.dat. [4] [5]
278061 for information on configuring Outlook or Microsoft KB 138053 for information on
configuring Exchange.
Logging
See the email logs for a description of what you can see in the system log.
Starting with the Dublin release, you can use these GlideSystem error messages to display messages:
For an information message:
gs.log("<INSERT LOG MESSAGE HERE>", "EMAIL." + sys_email.sys_id);
For a warning message:
gs.logWarning("<INSERT LOG MESSAGE HERE>", "EMAIL." + sys_email.sys_id);
For an error message:
gs.logError("<INSERT LOG MESSAGE HERE>", "EMAIL." + sys_email.sys_id);
References
[1] http:/ / www. rfc-editor. org/ info/ rfc2822
[2] https:/ / hi. service-now. com/ kb_view. do?sysparm_article=KB0524472
[3] https:/ / hi. service-now. com/ kb_view. do?sysparm_article=KB0521382
[4] http:/ / support. microsoft. com/ kb/ 278061
[5] http:/ / support. microsoft. com/ kb/ 138053
Examples of Inbound Email Actions 93
Note: The body and message fields on the Notification form were changed to body_html, body_text, message_html,
and message_text in the Eureka release.
Overview
These examples show how to create new task records with inbound email actions. The following examples are
shown:
Incident
Problem
Change Request
Creating an Incident
Inbound Email Actions allow users to log or update incidents on an instance via email. The Inbound Email Action
parses the email and responds using a script. Out-of-box, an email received by the instance creates a new incident,
and the body of the email is added to the Additional Comments text box. More refined Inbound Email Actions can
create incident tickets with more data, thus saving the incident management team valuable time.
gs.include('validators');
if (current.getTableName() == "incident") {
current.comments = "reply from: " + email.origemail + "\n\n" +
email.body_text;
if (email.body.assign != undefined)
Examples of Inbound Email Actions 94
current.assigned_to = email.body.assign;
if (email.body.category != undefined)
current.category = email.body.category;
if (email.body.short_description != undefined)
current.short_description = email.body.short_description;
current.update();
}
Creating a Problem
There are no Problem Management Inbound Email Actions provided in the base system. Below is an Inbound Email
Action for logging a problem.
email.subject.indexOf("Problem: ") == 0
current.description = email.body_text;
current.short_description = email.subject.toString().substring(9);
current.assignment_group.setDisplayValue("Development");
if (email.body.assign != undefined)
current.assigned_to = email.body.assign;
current.insert();
Examples of Inbound Email Actions 95
current.comments = email.body_text;
current.short_description = email.subject;
current.notify = 2;
if (email.body.assign != undefined)
current.assigned_to = email.body.assign;
if (email.body.priority != undefined)
current.priority = email.body.priority;
if (email.body.category != undefined)
current.category = email.body.category;
current.insert();
96
Reference
Notification Descriptions
Email Description Triggering Event Business Rule
Notification Controlling
Event
Approval Type: EMAIL An approval has been rejected includes the approvers approval.rejected approver events
Rejected name.
Approval Type: EMAIL An approval has been rejected includes the approvers approval.rejected.by.other approval events
Rejected by Other name.
Approval Request Type: EMAIL Sends an an email for the recipient to reply with an approval.inserted approver changes
approval decision. In the approval email, the recipient selects a link that
builds the appropriate reply email. See Approvals
Catalog Approval Type: EMAIL A catalog request has been rejected includes the request.approval.rejected approval events
Rejected approvers name.
Catalog Approval Type: EMAIL A catalog request for which you were an approver has request.approval.cancelled approver changes
Request been cancelled.
Catalog Approval Type: EMAIL A catalog request for which you are an approver has been request.approval.inserted approval events
Request made.
Certificate Type: EMAIL Notification that the ServiceNow X.509 certificate has certificate.expired certificate events
Expired expired.
Certificate Type: EMAIL Notification that the ServiceNow X.509 certificate is certificate.expiring certificate events
Expiring expiring in N days.
Change approved Type: EMAIL A change request has been approved. change.approved Change events and
task events
Change assigned Type: EMAIL A change request has been assigned to you. change.assigned Change events
to me
Change assigned Type: EMAIL A change request has been assigned to your group. change.assigned.to.group Change events
to my group
Out-of-Box Email Notifications 97
Change Type: EMAIL A comment has been added to a change request. The change.commented Change events
commented (to person assigned to the change request receives an email notification.
assignee)
Change Type: EMAIL A comment has been added to a change request. The change.commented Change events
commented assignment group assigned to the change request receives an email
(unassigned) notification.
Change Type: EMAIL Notification of a change in the fields label in a form. label.notify
Notification
Change rejected Type: EMAIL A change request has been rejected. change.rejected Change events and
task events
Change Task Type: EMAIL A work note has been added to a change task. The change_task.worknoted Change task
worknoted assignment group assigned to the change task receives an email events
(unassigned) notification.
Change Task Type: EMAIL A work note has been added to a change task. The person change_task.worknoted Change task
worknoted (to assigned to the change task receives an email notification. events
assignee)
Change Task Type: EMAIL A change task has been assigned to your group. change_task.assigned.to.group Change task
assigned to my events
group
Change Task Type: EMAIL A change task has been assigned to you. change_task.assigned Change task
assigned to me events
Change Type: EMAIL A work note has been added to a change request. The change.worknoted Change events
worknoted (to person assigned to the change request receives an email notification.
assignee)
Change Type: EMAIL A work note has been added to a change request. The change.worknoted Change events
worknoted assignment group assigned to the change request receives an email
(unassigned) notification.
Email assigned to Type: EMAIL An incident has been assigned to you (the recipient of the incident.assigned incident.events
email).
Email assigned to Type: EMAIL A task has been assigned to you (the recipient of the sc_task.assigned.to.user sc_task_events
(sc_task) email).
Email assigned Type: EMAIL An incident has been assigned to an assignment group of incident.assigned.to.group incident events
To Group which you are a member (the recipient of the email).
Email assigned to Type: EMAIL A Service Catalog task has been assigned to an sc_task.assigned.to.group sc_task_events
group (sc_task) assignment group of which you are a member (the recipient of the
email).
Incident Closed Type: EMAIL An incident opened by you (the recipient of the email), incident.updated incident events
has been closed.
Incident Type: EMAIL An incident opened by you (the recipient of the email) incident.commented incident events
Commented has had comments added. This notification uses a template for an
employee self-service (ESS) user.
Incident Type: EMAIL An incident assigned to you (the recipient of the email) incident.commented incident events
Commented has had comments added. This notification uses a template for an ITIL
user.
Out-of-Box Email Notifications 98
Incident Opened Type: EMAIL An incident has been opened for you (the recipient of the incident.inserted incident events
email) by someone else. This notification uses a template for an
employee self-service (ESS) user.
Incident Opened Type: EMAIL An incident has been opened and is unassigned. This incident.inserted incident events
& Unassigned notification uses a template for an ITIL user.
Incident Resolved Type: EMAIL An incident opened by you has been resolved, and incident.updated incident events
feedback is required to determine if the incident should be closed.
Knowledge Type: EMAIL A contributors submission to the Knowledge Base was kb.submission.closed_created KB event
Closed Created accepted and an article was created.
Knowledge Type: EMAIL A contributors submission to the Knowledge Base was kb.submission.closed_duplicate KB event
Closed Duplicate determined to be a duplicate, and no article was created.
Knowledge Type: EMAIL A contributors submission to the Knowledge Base was kb.submission.closed_invalid KB event
Closed Invalid determined to be invalid (unusable).
Notify Change Type: Meeting Invitation Notifies the recipients that a scheduled change change.calendar.notify.remove change events
Calendar Remove has been closed or assigned to someone else and removes the entry from
Problem Task Type: EMAIL A problem task has been assigned to you. problem_task.assigned Problem task
assigned to me events
Problem Task Type: EMAIL A problem task has been assigned to your group. problem_task.assigned.to.group Problem task
assigned to my events
group
Problem Task Type: EMAIL A work note has been added to a problem task. The problem_task.worknoted Problem task
worknoted (to person assigned to the problem task receives an email notification. events
assignee)
Problem Task Type: EMAIL A work note has been added to a problem task. The problem_task.worknoted Problem task
worknoted assignment group assigned to the problem task receives an email events
(unassigned) notification.
Problem Type: EMAIL A work note has been added to a problem. The person problem.worknoted Problem events
worknoted (to assigned to the problem receives an email notification.
assignee)
Problem Type: EMAIL A work note has been added to a problem. The problem.worknoted Problem events
worknoted assignment group assigned to the problem receives an email
(unassigned) notification.
Reminder Insert Type: Meeting Invitation Creates a calendar reminder regarding an open reminder.notify
[1]
task. The email is in the format of iCalendar formatted email
Reminder Insert Type: EMAIL Sends the recipient a reminder email about a specific reminder.notify.email
Email task.
Request Type: EMAIL A Service Catalog request, opened by the recipient, has sc_request.approved sc_request events
Approved been approved.
Request Assigned Type: EMAIL A Service Catalog request has been assigned to the sc_request.assigned sc_request events
recipient.
Out-of-Box Email Notifications 99
Request Type: EMAIL A Service Catalog request, opened by the recipient, has sc_request.updated sc_request events
Completed been completed.
Request Item Type: EMAIL An item requested from the Service Catalog has been sc_req_item.assigned sc_request events
Assigned assigned to you.
Request Item Type: EMAIL An item requested from the Service Catalog by the sc_req_item.delivery sc_request events
Delivery recipient is being delivered.
Request Opened Type: EMAIL A Service Catalog request has been opened on behalf of sc_request.requested_for sc_request events
on Behalf the recipient.
Reset Password Type: EMAIL The recipients password has been reset as requested. reset.password
Scheduled Import Type: EMAIL A scheduled import set has completed. scheduled_import_set.completed
Completed
System Upgraded Type: EMAIL The recipients ServiceNow system has been upgraded. system.upgraded
Task approved Type: EMAIL An ITIL task has been approved. task.approved Change events and
task events
Text Index Type: EMAIL A scheduled system index has completed. text_index.complete
Completed
Unscheduled Type: EMAIL A named configuration item has changed, and no active cmdb.unscheduled.change
Change change request exists.
Overview
Mail scripts [1] allow for business rule-like scripting within an outbound email message. With mail scripts, you can
dynamically change the email output of your system based on different criteria. Mail scripts allow you to perform
simple tasks, such as displaying incident data, and complex ones, such as making advanced database queries.
Create mail scripts in System Policy > Email > Notification Email Script starting with the Eureka release. Then
add a ${mail_script:script name} embedded script tag to the body of the email notification [3] or
template [4], replacing script name with the name of the script you created. This makes it easy to use the same
scripts in multiple email notifications or templates.
Mail scripts are added directly in the Message field when creating email notifications or email templates in versions
prior to Eureka.
Scripting for Email Notifications 100
${URI+&sysparm_scriptlet=current.assigned_to=gs.getUserID()
&sysparm_scriptlet_condition=current.assigned_to.nil()
&sysparm_view=incident_active}
current.assigned_to=gs.getUserID()
current.assigned_to.nil()
Related Record to Provide Link to Notification record table Reference Field Samples
Related task record to be approved from an approval Approval Approval for ${sysapproval.URI}
notification [sysapproval_approver] [sysapproval] ${sysapproval.URI_REF}
For example, the following notification template produces the email links in the picture below:
${CMS_URI+<site>/<page>}
For example, to link the email recipient to a page called Incident in the content site ESS, with the current incident as
the target document, use the following format:
${CMS_URI+ess/incident_detail}
The resulting email URL has this format:
https://<instance
name>.service-now.com/ess/incident_detail.do?sysparm_document_key=incident,46e18c0fa9
Scripting for Email Notifications 102
Examples
...
email.setFrom(current.caller_id.email);
email.setReplyTo("[email protected]");
email.setSubject("This is the new subject line");
email.setBody("This is the new body");
...
Scripting for Email Notifications 103
function dothis() {
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id',current.sys_id);
gr.query();
while (gr.next()) {
template.print('Attachment: <a href="https://' + gs.getProperty('instance_name') + '
.service-now.com/sys_attachment.do?sys_id=' + gr.sys_id +
'">' + gr.file_name + '</a>');
}
}
The following is an example script to add users from watch_list as copied recipients.
if (!current.watch_list.nil()) {
//get watch list addresses and add to cc
var watcherIds = current.watch_list.split(",");
while (user.next()) {
//add to cc list
email.addAddress("cc", user.email, user.getDisplayValue());
}
}
Scripting for Email Notifications 104
template Handles printing from the mail script to the email message.
template.print("message"); //outputs message to the email body.
template.space("number of spaces"); //outputs spaces to the email body.
event GlideRecord object for the event that fired the notification (sysevent).
References
[1] https:/ / docs. servicenow. com/ bundle/ helsinki-servicenow-platform/ page/ script/ server-scripting/ concept/
c_ScriptingForEmailNotifications. html
[2] http:/ / docs. servicenow. com
[3] https:/ / docs. servicenow. com/ bundle/ helsinki-servicenow-platform/ page/ administer/ notification/ reference/ notifications. html
[4] https:/ / docs. servicenow. com/ bundle/ helsinki-servicenow-platform/ page/ administer/ notification/ concept/ c_EmailTemplates. html
Article Sources and Contributors 105
Notifications Source: http://wiki.servicenow.com/index.php?oldid=249064 Contributors: CapaJC, Emily.partridge, Fuji.publishing.user, G.yedwab, George.rawlins, Ishrath.razvi, Joe.Westrich,
Joe.zucker, Joseph.messerschmidt, Phillip.salzman, Publishing.user, Rachel.sienko, Steven.wood
Configuring Email Properties Source: http://wiki.servicenow.com/index.php?oldid=74619 Contributors: Aburruss, CapaJC, Cheryl.dolan, David Loo, David.Bailey, Don.Goodliffe,
Emily.partridge, Fuji.publishing.user, G.yedwab, Guy.yedwab, Joseph.messerschmidt, Neola, Phillip.salzman, Rachel.sienko, Steven.wood, Suzanne.smith, Vaughn.romero, Vhearne, Wallymarx
Enabling the Email Client Source: http://wiki.servicenow.com/index.php?oldid=249055 Contributors: CapaJC, Chuck.tomasi, David Loo, Don.Goodliffe, Emily.partridge, Fuji.publishing.user,
G.yedwab, Guy.yedwab, Jay.berlin, Jessi.graves, Joseph.messerschmidt, Phillip.salzman, Rachel.sienko, Steven.wood, Suzanne.smith, Vaughn.romero, Vhearne
Events and Email Notification Source: http://wiki.servicenow.com/index.php?oldid=247121 Contributors: CapaJC, Chuck.tomasi, Emily.partridge, G.yedwab, Grant.hulbert, Guy.yedwab,
Ishrath.razvi, Jgrinter, Joe.Westrich, Joseph.messerschmidt, Mark.stanger, Neola, Phillip.salzman, Rachel.sienko, Steven.wood, Vaughn.romero, Vhearne
Email Notifications Source: http://wiki.servicenow.com/index.php?oldid=249105 Contributors: Bow, CapaJC, Cheryl.dolan, Christen.mitchell, David Loo, Emily.partridge,
Fuji.publishing.user, G.yedwab, Gareth.robertson, Grant.hulbert, Guy.yedwab, Ishrath.razvi, Jay.berlin, Jerrod.bennett, Jessi.graves, Joe.Westrich, John.roberts, Joseph.messerschmidt,
Myla.jordan, Neola, Pat.Casey, PaulMorrison, Peter.smith, Phillip.salzman, Publishing.user, Rachel.sienko, Ray.lee, Richard.motteram, Rob.woodbyrne, Steven.wood, Suzanne.smith,
Vaughn.romero, Vhearne
Email Templates Source: http://wiki.servicenow.com/index.php?oldid=244612 Contributors: Emily.partridge, Fuji.publishing.user, G.yedwab, Guy.yedwab, Joe.zucker, Joseph.messerschmidt,
Mark.stanger, Neola, Publishing.user, Rachel.sienko, Steven.wood, Suzanne.smith, Vaughn.romero
Notification Examples Source: http://wiki.servicenow.com/index.php?oldid=247587 Contributors: G.yedwab, Joseph.messerschmidt, Phillip.salzman, Rachel.sienko, Steven.wood,
Vaughn.romero
Subscription Based Notifications Plugin Source: http://wiki.servicenow.com/index.php?oldid=82800 Contributors: CapaJC, Dawn.bunting, Dkearney, Emily.partridge, Fuji.publishing.user,
G.yedwab, Gadi.yedwab, Guy.yedwab, Ishrath.razvi, Jerrod.bennett, Jessi.graves, Joseph.messerschmidt, Mark.stanger, Phillip.salzman, Publishing.user, Rachel.sienko, Steven.wood,
Vaughn.romero, Vhearne
Setting Up Subscription Based Notifications Source: http://wiki.servicenow.com/index.php?oldid=247869 Contributors: Annmarie, Emily.partridge, Fuji.publishing.user, G.yedwab,
John.roberts, Joseph.messerschmidt, Phillip.salzman, Rachel.sienko, Roy.lagemann, Steven.wood
Using Subscription Based Notifications Source: http://wiki.servicenow.com/index.php?oldid=247947 Contributors: Emily.partridge, Fuji.publishing.user, G.yedwab, Guy.yedwab,
Ishrath.razvi, Joe.Westrich, Joe.zucker, Joseph.messerschmidt, Kenny.gabel, Peter.smith, Phillip.salzman, Rachel.sienko, Roy.lagemann, Steven.wood
Inbound Email Actions Source: http://wiki.servicenow.com/index.php?oldid=249709 Contributors: Anat.kerry, Bsweetser, CapaJC, Cheryl.dolan, David Loo, David.Bailey, Emily.partridge,
Fuji.publishing.user, G.yedwab, Gflewis, Grant.hulbert, Guy.yedwab, Jessi.graves, Joe.Westrich, John.roberts, Joseph.messerschmidt, Julie.phaviseth, Nick.roberts, Peter.smith, Phillip.salzman,
Publishing.user, Rachel.sienko, Steven.wood, Suzanne.smith, Vaughn.romero, Vhearne
Examples of Inbound Email Actions Source: http://wiki.servicenow.com/index.php?oldid=247462 Contributors: G.yedwab, Guy.yedwab, Joseph.messerschmidt, Neola, Phillip.salzman,
Rachel.sienko, Steven.wood, Vaughn.romero
Out-of-Box Email Notifications Source: http://wiki.servicenow.com/index.php?oldid=145192 Contributors: David Loo, G.yedwab, Guy.yedwab, Joe.Westrich, Joseph.messerschmidt, Neola,
Rachel.sienko, Steven.wood, Suzanne.smith, Vaughn.romero
Scripting for Email Notifications Source: http://wiki.servicenow.com/index.php?oldid=249894 Contributors: Anat.kerry, CapaJC, David Loo, Emily.partridge, G.yedwab, George.rawlins,
Guy.yedwab, Jerrod.bennett, Jessi.graves, Joe.Westrich, Joe.zucker, Joey.mart, John.roberts, Joseph.messerschmidt, Mark.stanger, Myla.jordan, Neil.narvaez, Neola, Phillip.salzman,
Rachel.sienko, Rob.woodbyrne, Steven.wood, Vaughn.romero, Vhearne, Voytek.blonski
Image Sources, Licenses and Contributors 106