Help with approval link.

nkpanesar
Kilo Contributor

Hello All,  I need help in generating link to the approval page.

Below is What I have done so far, but I get "record not found" everytime I click on "this link".Seems like its picking wrong sysid, but need guidance how to get this working.

Requirement:

Approver gets email with link to approve a given RITM, this link should take him to the approval page. I have Admin rights, so its not a permission issue.

find_real_file.png

When I click on "This link" Getting Record could not be found.

find_real_file.png

The Script that generates the link is below:

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {

var url = 'https://'+ gs.getProperty("instance_name") +'.service-now.com/biomarin_sp?id=approval&table=sysapproval_approver&sys_id='+current.sys_id;
template.print('<a href='+url+'>this link</a>');

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

The notification that triggers this script is defined in the WF itself:

find_real_file.png

find_real_file.png

5 REPLIES 5

Harish Ragz
Kilo Guru
Hi nkpanesar,
 
Once try the below script.....
 
var link = "https://"+ gs.getProperty('instance_name') +".service-now.com/biomarin_sp?id=approval&table=sysapproval_approver&sys_id="+current.sys_id;
var url = '<a href="' + link + '"> This Link</a>';
template.print(url);
 
Thanks,
Hareesh.

 

Hello Harish, I updated the script and still get Record not found. 

 

jschlieszus
Kilo Guru

nkpanesar,

 

you may be correct with using the wrong sys id.  The first question would what is triggering this notification and what exactly current.sys_id is referring to.  If this is triggered from a RITM, where current is sc_req_item, then yes, the current.sys_id would not give you a valid approval record.

 

If that is the case there are several things you could do, trigger event from approvals table, or in the mail script, query for the appropriate approval related to your RITM and use that record sys id.

Yes, I think its picking from sc_req_item.

 

I do not want to make event based notification, can you help with updating the query to look for right table?