- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2023 05:27 PM
In the service catalog, an email notification is sent when the status of a task changes to work in progress, but I would like to include the RITM and SCTASK links in the email body at that time. Is there any way to do this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2023 12:51 AM
Hi @Ryota ,
use template.print('<a href="' + link + '">' + Link to RITM + '</a>');
Thanks,
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2023 10:43 PM
Sure,
There might already be some example is the existing notifications if you browse around, but basically you can use an email script to add a dynamic link.
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var link = '';
//code to generate link
template.print('<a href="' + link + '">');
})(current, template, email, email_action, event);
Then the mail script can be connected to the notification with
${mail_script:<script_name>}
So, what should the link be like? Up to you. You could just copy how it is when you open a record from list and instead just replace the sys_id with current.sys_id or the one from a related record that you've queried.
For example:
var link = "/sc_req_item.do?sys_id=" + current.sys_id;
Email scripts can be found under "Notification Email Scripts" in the navigation menu.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2023 10:47 PM
Hi @Ryota ,
If notification is on sctask table then use below suggestions.
1.To print sctask number use ${URI} or ${URI_REF} in notification body.
2. To print RITM link create email script with below code and call that script from notification body.
var link = gs.getProperty('glide.servlet.uri') + '/now/nav/ui/classic/params/target/sc_req_item.do%3Fsys_id%3D' + current.request_item.toString();
template.print('<a href="https://'+link+'>Link to RITM</a');
How to call email script: ${mail_script:script name}
Thanks,
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2023 12:43 AM
Hi Gopi
Thank you for your reply. Could you please tell me a little more details. I copied the code below but it didn't work. Do I need to add anything else to the underlined part? For example, instance name and workspace_name etc..
template.print('<a href="https://'+link+'>Link to RITM</a');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2023 12:51 AM
Hi @Ryota ,
use template.print('<a href="' + link + '">' + Link to RITM + '</a>');
Thanks,
Gopi