- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2020 02:02 AM
Hello Folks,
I want to put a dynamic hyperlink with the dynamic text in notification. Below is an example:
Table: announcement
fields: details_url, details_link_text (URL given in the field)
var URL = current.details_url; (normal text)
var link = current.details_link_text;
I want to print the "current.details_link_text" in email script, When we click on the "current.details_link_text" It should take me to the URL i.e current.details_url.
Can anybody help me out here ?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2020 02:11 AM
Hi. Below is the script you need.
It's a bit confusing to name the link URL and the text - link, but it's okay if you understand it like this.
Name your emal script script for example 'getDinamicUrl', then in the notification call ${mail_script:getDinamicUrl}
Please mark Correct and Helpful. Thanks!
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var URL = current.details_url;
var link = current.details_link_text;
// Add your code here
template.print('<a href="'+URL+'" style="font-family: verdana, geneva; font-size: 12pt;">'+link+'</a>');
})(current, template, email, email_action, event);
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2020 02:11 AM
Hi. Below is the script you need.
It's a bit confusing to name the link URL and the text - link, but it's okay if you understand it like this.
Name your emal script script for example 'getDinamicUrl', then in the notification call ${mail_script:getDinamicUrl}
Please mark Correct and Helpful. Thanks!
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var URL = current.details_url;
var link = current.details_link_text;
// Add your code here
template.print('<a href="'+URL+'" style="font-family: verdana, geneva; font-size: 12pt;">'+link+'</a>');
})(current, template, email, email_action, event);
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2020 02:24 AM
Please follow the steps shared by Martin and they should help you
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2025 05:20 AM
Hi Marin,
If I wish to separate text and URL, then how can I achieve this, for example I have a field string type (u_work_notes) and another URL field type (u_url) and value entered u_work_notes is "try this link" and in URL field mentioned - "www.xyz.com" then i want output - try this link www.xyz.com(this being hyperlink).
Can you please let me know the possible way to achieve the same