How to add SCTASK URL in notification which is created on sc_req_item table ?

Pallavi Shinde
Tera Contributor

Hello,

 

I have requirement to add SCTASK URL in notification email body which is created on sc_req_item table. 

Please suggest the how to achieve it. 

If it is achieved by email script please share.

 

Thanks

 

2 REPLIES 2

sanketpatil09
Tera Guru

To create a notification for the Requested Item [sc_req_item] table, set the trigger condition to "on Record Inserted." Specify the intended recipient(s), such as "Requested for," "Assigned to," or any user field associated with the record. In the "What it will contain" tab:

sanketpatil09_0-1736398364323.png

 

  • The ${URI} variable in the email body dynamically generates the URL pointing to the current record (in this case, the SCTASK).
  • Recipients clicking the link in the email will be redirected to the SCTASK form in ServiceNow.

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Pallavi Shinde 

something like this but please enhance it

(function runMailScript(current, template, email, email_action, event) {

    // Add your code here
    var gr = new GlideRecord("sc_task");
    gr.addQuery("request_item", current.sys_id);
    gr.query();
    while (gr.next()) {
        var link = gs.getProperty('glide.servlet.uri') + 'sc_task.do?sys_id=' + gr.sys_id;
        template.print('<a href="' + link + '">Link to SCTASK</a><br/>');
    }

})(current, template, email, email_action, event);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader