- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 09:14 PM
Hi team,
In the notification instead of using ${url_ref}, we need to write the email script to link.
Can someone help here.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 10:03 PM
Thanks for the response. Actually it's working when I given dev instance. But I will move to next environment right, that time how will instance name changes? Can you pls help me here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 09:43 PM
Hi @PRAGHATIESH S
Add a Mail Script:
- In the content of the notification (either in the “Message HTML” or “Message Text” field), you can use a mail script to generate your custom URL.
- You will use ${mail_script:script_name} placeholder to call your custom mail script.
Create the Mail Script:
- Navigate to System Notification -> Email Scripts.
- Click on the “New” button to create a new email script.
- Provide a name for your script, such as “Custom URL Script”.
- Set “Applies to” to All.
- In the “Script” field, write your script to generate the URL. Below is an example of a script that generates a URL for an incident:
// Example email script: Custom URL Script
var gr = current;
var url = gs.getProperty(‘glide.servlet.uri’);
url += ‘nav_to.do?uri=incident.do?sys_id=’ + gr.sys_id;
template.print(‘<a href="’ + url + ‘">View Incident</a>’);
Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 09:49 PM - edited 05-27-2024 09:49 PM
Hello,
You can use the below code to add a hyperlink to the email body.
Replace the number field and table_name according to your need.
function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Add your code here
template.print('<a href="https://' + gs.getProperty('instance_name')+ '.service-now.com/<table_name>.do?sys_id=' + current.sys_id+'">' + current.number + '</a>' );
})(current, template, email, email_action, event);
Thanks,
MItesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 10:03 PM
Thanks for the response. Actually it's working when I given dev instance. But I will move to next environment right, that time how will instance name changes? Can you pls help me here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 10:28 PM
Sorry, working fine.
Thanks for the solution.