To link a ServiceNow email notification to the record that triggered it, place the ${URI} token in the message body. The reader sees the word LINK. Use ${URI_REF} when the record’s display value should be the link text. Workspace records need a mail script instead, because these tokens do not apply there.
How the record link tokens work
A notification body is a template. Each token inside it is replaced with a value taken from the record that fired the notification, so the ${URI} token becomes a link to that specific record. One template can serve many incidents or requests, and each recipient receives a link to the record that caused the message.
When a reader clicks the link, the instance checks whether they are logged in. If they are not, it asks them to log in, then redirects them to the record named in the link. Tokens go in the Message HTML field on the What it will contain tab of the notification form.
Choosing between the LINK text and the display value
The two basic tokens differ in the words the reader sees. ${URI} displays the word LINK. ${URI_REF} displays the record’s display value, so the reader sees the name of the thing they are opening. The URI+ form, covered below, is the one that adds extra arguments such as sysparm terms to the link. For the concept behind the display value, see display value.
| Token | What the reader sees | What it adds to the link | Typical use |
|---|---|---|---|
| ${URI} | The word LINK | The standard record link | A short call to action |
| ${URI_REF} | The record’s display value | The standard record link | A message where the record name should show |
| ${URI+…} | The standard record link, with extra arguments appended | Extra arguments such as sysparm terms | A link that also sets a value or opens a view |
The URI+ form keeps the automatically built record link and appends arguments to it. One worked example appends a scriptlet that sets the assigned-to field to the current user, a condition that runs that scriptlet when the assigned-to field is empty, and a view parameter that opens the incident_active view. The click therefore does more than open the record: it can also write a value, when the stated condition holds.
Linking to a related record
To link to a record behind the one that triggered the message, place the reference field name in front of the token, followed by a dot. The two forms are ${reference-field.URI} and ${reference-field.URI_REF}. For the general mechanism, see dot-walking.
A worked example links to a related problem from an incident notification, with the reader seeing the problem’s display value as the link text. Some records will have an empty reference field, and then there is no related record to point to. Write the sentence so it still reads sensibly without the link, and test with a record that has the reference filled in and one that does not.
Linking to records opened in Workspace
The ${URI} and ${URI_REF} tokens do not apply to records in Workspace. A link built with them does not take a Workspace user to the record in the Workspace interface. For those records, use a mail script: a small script that builds the link and prints it into the message.
- Write the mail script, either typed between mail_script tags in the Message HTML field and converted on save, or already stored as an Email Script [sys_script_email] record.
- Open the notification, go to the What it will contain tab, and embed the script in the Message HTML field with ${mail_script:script_name}.
- Make the script print a URL in this form: the instance address, then /now/workspace/, the workspace name, /record/, the table name, and the record’s sys_id.
The example script builds that address from the system property holding the instance address, the Agent workspace path, the table name of the current record, and the record’s sys_id. It wraps the record number in an HTML anchor and writes the result with the template print method, followed by a line break.
If the instance has an HTML sanitizer configuration, embed the script as ${{mail_script:script_name}} with double braces, so its output is sanitized. Without a sanitizer, use the single-brace form.
A mail script can also be typed straight into the body between mail_script tags. On saving a notification with a typed script, the form asks whether to convert it. Choosing Yes moves the script to the Email Script table and places the embedded tag in its position. Once converted, the script is stored as an Email Script record, and any notification can embed it. For the email template page, see email template.
Mail script objects
Mail scripts have a few objects available. The template object handles output: template.print writes text into the message, and template.space writes blank spaces. The event object is a GlideRecord for the event that fired the notification. The email_action object is a GlideRecord for the notification record. The email object lets a script add cc or bcc recipients with addAddress, and override the sender, reply-to address, subject or body with setFrom, setReplyTo, setSubject and setBody.
Addresses passed to setFrom and setReplyTo must be valid: a plain address, or a display name followed by the address in angle brackets. A display name supplied this way replaces the instance’s display name for that message.
Other tokens in the same family
An email layout sets the surrounding look of a message, and the notification’s body sits inside it, so one layout can serve many notifications.
The ${NOTIF_UNSUB} token creates an unsubscribe option that works by email. The ${NOTIF_PREFS} token links the reader to their notification preferences, which requires signing in. Both accept a link_text parameter in quotation marks to set the words shown. Administrators can add these macros to email layouts, templates and notifications.
The ${CMS_URI+site/page} token creates a link to a CMS page on the instance. The text after the plus sign is the relative path to the CMS site and page, such as ess/incident_detail.
Checking the notification before it sends
The Notification form has four tabs: When to send, Who will receive, What it will contain, and What Digest will contain. The digest tab appears when Allow Digest is selected.
Recipients must be active users with a valid email address on their primary channel, held in the Notification Device table. A user who is inactive does not receive the message, even when named in a recipient field. For a subscribable notification, each recipient also needs the notification and its channel enabled in their notification preferences.
Use Preview Notification after you create or update the notification, and save the record first so the preview is accurate. The preview shows how the Subject and Message fields display and lets you test the links you have added. Users who will not receive the message appear in red strikethrough, and hovering over the name shows the reason. If the template links to the triggering record, the preview uses that record, and you can click through to it.
Two sending behaviors matter for large audiences. The SMTP Sender scheduled job decides how often email goes out, and by default it runs each minute. A notification with more than 100 intended recipients is split into messages of up to 100 recipients each. That limit is set by the glide.email.smtp.max_recipients system property, and 1000 users is the suggested ceiling for one notification’s recipient list. If a notification does not arrive at all, see the page on email notifications not sending.
Duplicate handling also matters when two notifications fire from the same change. Notifications with the same target table and recipients are duplicates when their weights differ. The system sends the one with the highest weight and moves the others from the outbox to the skipped mailbox. A default weight of 0 still causes a notification to send. When weights are equal, the subject and body, excluding the watermark, decide whether the two are duplicates.
Security and setup mistakes to avoid
Notifications are not filtered by access controls. Recipients can receive email about records they cannot open in the interface, such as a requester who gets a message about a request opened for them. For notifications carrying sensitive data, restrict the recipient list, avoid the subscribable option, and insert a link back to the record so the details stay out of the message. For the wider access design, see notification security and access design.
Do not select the Task table for a notification. It exists to be extended by other tables, and notifications that run on the Task table directly are not supported. Choose the table that holds the actual records, such as an incident or a request. Also avoid leaving the category as Uncategorized, since users may not find the notification in their list of notifications.
Frequently asked questions
Why does my link say LINK?
That is the ${URI} token, which uses the word LINK as its link text. Use ${URI_REF} to show the record’s display value instead.
Why does the link not open a Workspace record?
The ${URI} and ${URI_REF} tokens do not apply to records in Workspace. Build the link with a mail script that prints a Workspace record address, and embed that script in the Message HTML field.
Can a notification link to a related record?
Yes. Place the reference field name and a dot in front of the token, so the link points at the related record rather than the triggering record.
Does the reader have to sign in?
If they are not already logged in, the instance asks them to log in when they click the link, then redirects them to the record.
How can I test links before a notification goes out?
Use Preview Notification after you create or update the notification. It shows how the Subject and Message display, lets you test the links, and marks any recipient who will not receive the message in red strikethrough, with the reason on hover.
Why did one of two similar notifications not arrive?
Notifications with the same target table and recipients are treated as duplicates when their weights differ, or when their weights match and their subject and body match. The system sends the one with the highest weight and moves the others to the skipped mailbox.