- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2018 11:16 AM
I'm looking for a script that will list out the members of an approval group and their emails that the current request is waiting for approval from. This is so the Requester will know who to contact if an approval is taking too long. The notification is being built in the actual workflow. Any help is appreciated.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2018 12:57 AM
HI,
Here you go:
Use this below mail script :
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Add your code here
gs.log('Sys Id '+current.sys_id,'Munot');
var arr = [];
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('document_id',current.sys_id);
gr.addQuery('state','requested');
gr.query();
while(gr.next())
{
arr.push(gr.approver.toString());
}
template.print('arr'+arr);
var rows;
for(var i=0;i<arr.length;i++)
{
gs.log('User Id '+arr[i],'Munot');
var usr = new GlideRecord('sys_user');
usr.addQuery('sys_id',arr[i]);
usr.query();
if(usr.next())
{
gs.log('inIf','Munot');
rows += '<tr>';
rows += '<td>' + usr.first_name + '</td>';
rows += '<td>' + usr.email + '</td>';
rows +='</tr>';
}
}
var data;
data = '<table style="border-collapse: collapse;" border="1" cellpadding="5"><tbody>';
data += '<tr><th>Name</th><th>Email Id</th></tr>';
data += rows;
data += '</tbody></table>';
template.print(data);
})(current, template, email, email_action, event);
Results are as below:
Use this in notification:
${mail_script:remaining.approver} //remaining.approver is my mail script name
Thanks,
Ashutosh Munot

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2018 12:57 AM
HI,
Here you go:
Use this below mail script :
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Add your code here
gs.log('Sys Id '+current.sys_id,'Munot');
var arr = [];
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('document_id',current.sys_id);
gr.addQuery('state','requested');
gr.query();
while(gr.next())
{
arr.push(gr.approver.toString());
}
template.print('arr'+arr);
var rows;
for(var i=0;i<arr.length;i++)
{
gs.log('User Id '+arr[i],'Munot');
var usr = new GlideRecord('sys_user');
usr.addQuery('sys_id',arr[i]);
usr.query();
if(usr.next())
{
gs.log('inIf','Munot');
rows += '<tr>';
rows += '<td>' + usr.first_name + '</td>';
rows += '<td>' + usr.email + '</td>';
rows +='</tr>';
}
}
var data;
data = '<table style="border-collapse: collapse;" border="1" cellpadding="5"><tbody>';
data += '<tr><th>Name</th><th>Email Id</th></tr>';
data += rows;
data += '</tbody></table>';
template.print(data);
})(current, template, email, email_action, event);
Results are as below:
Use this in notification:
${mail_script:remaining.approver} //remaining.approver is my mail script name
Thanks,
Ashutosh Munot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2018 08:57 AM
That works great, is there anyway to remove the user's sys_id's from displaying above the table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2018 09:21 AM
Nevermind, figured it out. Thanks again!