How do I pull in 'Approver Name' and 'Rejection' comment's in to Notification?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2018 01:31 AM
Hi Community,
In the process of creating a Notification that in the event of a Service Catalog request being rejected by an approver then the Requestor will be informed of this. I have started off by creating a Notification that trigger on ‘Approval’ changes to ‘Rejected’ (in the Request itself). It all looks good so far but could also do with pulling in the ‘Approvers’ name and reason (‘comment’) for rejection in to this Notification as useful.
My Notification triggers against Table: 'Request [sc_request]’ and the approvers name and reason for rejecting is stored in Table: 'Approval [sysapproval_approver]'
Question: How do I pull the ‘Approvers’ name and ‘Rejection’ comment in to the Notification as this information is stored in a different table?
I guess if the Notification triggered on the Approval [sysapproval_approver] table it could be something like this:
The following comments were given by Approver: ${approver} about the rejection
<hr/>
Comments: ${comments}
But as my Notification is triggered on 'Request [sc_request] table then how will it link to be able to pull in the information (Approver's name & rejection comment) from this other table where the info I need is stored?
Grateful for advice😉

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2018 02:12 AM
Hi Henrik,
You need to use mail script for achieving the same. Find the untested one as below
Mail script: get_approver_comments
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var ritmchk=new GlideRecord('sc_req_item');
ritmchk.addQuery('request',current.sys_id);
ritmchk.query();
while(ritmchk.next())
{
//template.print('Ritm sys id is '+ritmchk.sys_id);
var approvalchk=new GlideRecord('sysapproval_approver');
approvalchk.addQuery('sysapproval',ritmchk.sys_id);
approvalchk.query();
while(approvalchk.next())
{
template.print('approver is '+approvalchk.approver);
}
}
})(current, template, email, email_action, event);
Once done use this in notification created on request table as ${mail_script:get_approver_comments}
Thanks,
Jaspal Singh
Hit Helpful or Correct on the impact of response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2018 03:26 AM
Hi Jaspal,
Thank you for pointing me in the right direction as agree a script is the way forward.
I applied the script provided to an 'Email Script' and applied the name of Script to the Email Template I use for the Notification but still coming out as blank.
Could it be that the script take a while to replicate or have I applied it incorrectly? See image:
Thanks Jamal!!