Is there a way to include the RITM and SCTASK links in the body of the notification email?

Ryota
Tera Guru

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?

1 ACCEPTED SOLUTION

Hi @Ryota ,

use template.print('<a href="' + link + '">' + Link to RITM + '</a>');

 

 

If my solutions helps you to resolve the issue, Please accept solution and Hit "Helpful".

Thanks,
Gopi

View solution in original post

6 REPLIES 6

Weird
Mega Sage

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. 

Gopi Naik1
Kilo Sage

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}

 

 

 

If my solutions helps you to resolve the issue, Please accept solution and Hit "Helpful".

Thanks,
Gopi

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');

Hi @Ryota ,

use template.print('<a href="' + link + '">' + Link to RITM + '</a>');

 

 

If my solutions helps you to resolve the issue, Please accept solution and Hit "Helpful".

Thanks,
Gopi