- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2025 01:53 PM
I'm working on a requirement where, whenever a case is created in ServiceNow, an email notification should be triggered. The email body needs to include a direct URL link to the same case record, but on a different/external platform.
The URL format is standard and looks like this, where the sys_id should dynamically pull from the current case record in ServiceNow:
https://TEST.DEMO.com/tickets/lib/{sys_id}/edit
For example, if the sys_id of the case is 7d1f540997e96290be01bb1ad053af06, the final link would be:
https://TEST.DEMO.com/tickets/lib/7d1f540997e96290be01bb1ad053af06/edit
My questions:
What’s the best way to include this dynamic link in the email body?
Should I use an Email Script, or is there another recommended approach?
I’ve tried both approaches but have run into issues where the sys_id does not render as expected in the final email.
Example Notification Template (HTML):
<a href="https://TEST.DEMO.com/tickets/lib/${sys_id}/edit">
https://TEST.DEMO.com/tickets/lib/${sys_id}/edit
</a>
Sample mail script:
(function runMailScript(current, template, email, email_action, event) {
var link = "https://TEST.DEMO.com/tickets/lib/" + current.sys_id + "/edit";
template.print('<a href="' + link + '">' + link + '</a>');
})();
Would appreciate any advice or examples from those who’ve successfully done this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 06:42 AM
you can include link like this
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2025 02:49 PM
Hi @Tyler33,
You should be able to use the ${sys_id} within the email notification without writing a mail script.
If you are triggering the email notification from a specific table, you can fetch the ${sys_id}, i.e.
What do you mean by sys_id does not render as expected? Are you saying there is no value in the parameter or something else?
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 06:37 AM
Thanks James,
I've tried both a mail script and embedding it directly in the template. I've also confirmed that if I just use ${sys_id} by itself (not inside the URL), it does populate correctly in the notification.
What I meant by “sys_id does not render as expected” is that in the email that gets sent, the placeholder ${sys_id} just shows up as-is in the final output — literally ${sys_id} — instead of being replaced with the actual sys_id value from the record.
So rather than a full URL like:
https://TEST.DEMO.com/tickets/lib/7d1f540997e96290be01bb1ad053af06/edit
I'm getting this in the email:
https://TEST.DEMO.com/tickets/lib/${sys_id}/edit
This happens even though the notification is tied to the case table and triggered when a new case is inserted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 06:51 AM
The sys ID that I am attempting to add to the URL does not show up as-is in the final output — it just says ${sys_id} in the notification.
On the bottom of the template where I have Sys ID: ${sys_id} - this appends the correct sys_id as expected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 06:42 AM
you can include link like this
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader