Help with approval link.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2018 09:41 AM
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.
When I click on "This link" Getting Record could not be found.
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:
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2018 11:13 AM
In the mail script you could query the sysapproval_approver table for an active approval for the RITM,
var approvalGR = new GlideRecord('sysapproval_approver');
approvalGR.addEncodedQuery('state=requested^sysapproval=' + ritm.sys id'); //assuming this is current then current.sys_id
approvalGR.query('approver', user_id, event.parm1?2?) //this lets you pinpoint in case you have multiple for the RITM
approvalGR.query();
if(approvalGR.next()){
//if only one then get the sys id of approvalGR, if multiple you an construct your url with multiple sys_id=id^ORsys_id=id : etc
}