how to use variable input as hyperlink in email notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2025 02:15 AM
Hi All,
I have variable in my catalog item which is single line text and it input value contains url and in email notification I want to use that input as hyperlink for the word URL.
Sample:
Thank you!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2025 04:27 AM
create email script and include that in your notification body like this
${mail_script:mailScriptName}
Email script
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
template.print('<a href="' + current.variables.variableName + '">Click here to view link</href>');
})(current, template, email, email_action, event);
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2025 07:09 PM
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2025 04:45 AM - edited 11-15-2025 04:54 AM
Hi @Kiruthika J
To do so, use "Email Script", then use that email script in your Notification.
Email Script:
(function runMailScript(current, template, email, email_action, event) {
template.print('<a href="' + current.variables.variableName + '" target="_blank"> Click Here </a>');
})(current, template, email, email_action, event);
To use this email script in your notification, add this as
${mail_script:<<name of the script you created>>}
Also check out this:
https://www.youtube.com/watch?v=PpWMFORUsv0
-------------------------------------------------------------------------------------------------------------------------------------------
If my response solves your query, please marked helpful by selecting accept as Solution and Helpful. Let me know if anything else is required.
Thanks,
Prerna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2025 07:21 AM
you can achieve this by creating a Mail Script (under System Notification → Email → Notification Email Scripts) that reads the catalog item variable (e.g. current.variables.your_variable_name) and prints it as an HTML link, for example.......
(function runMailScript(current, template, email, email_action, event) {
var url = current.variables.your_url_variable;
if (url) {
template.print('<a href="' + url + '" target="_blank">URL</a>');
}
})(current, template, email, email_action, event);
Then in your Notification message you include it like this....
${mail_script:your_mail_script_name}
If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.
Kaushal Kumar Jha - ServiceNow Technical Consultant - ServiceNow Class of Legends 2025