- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2020 02:59 AM
Hello,
Need to get approver name in notification.
ex - when change request is going to approval, i need approver name in HTML template.
Can anyone please help me with this.
Regards,
Nivedita
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2020 05:12 AM
Hi Nivedita,
Replace approv.query(); with below in your code once.
approv.addQuery('state','approved');
approv.orderByDesc('sys_upated_on');
approv.query();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2020 03:08 AM
Hello ,
On which table you have that HTML field,Also how you are sending approval, i hope it is triggering through workflow,if yes please share the code.
Regards
Yash Agrawal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2020 03:09 AM
Hi Nivedita,
What table notification is on.
If it is on Approval table you can get it readily from Approver field.
If it is on Change request table you need to use mail scirpt that GlideRecords Approval table & gets the name. Something as below.
Mail script: getapprovername
Script:
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var getname=new GlideRecord('change_request');
getname.addQuery('sys_id',current.sys_id);
getname.query();
while(getname.next())
{
template.print('Approvers are '+getname.approver.getDisplayValue()+'\n');
}
})(current, template, email, email_action, event);
Use the same in notification body in format
${mail_script:getapprovername}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2020 03:09 AM
HI,
Write a email script as below and call that in your notification:
var appName = new GlideRecord('sysapproval_approver');
appNew.addQuery('document_id',current.getValue('sys_id'));
appNew.addQuery('state','approved');
appNew.query();
if(appNew.next()){
template.print('Approver Name is : '+appNew.approver.getDisplayValue());
}
Thanks,
Ashutosh
call in this email body as below:
${mail_script:scriptName}
-Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2020 02:22 AM
Thank you for your reply.
I have written below code but it is not working.
var appName = new GlideRecord('sysapproval_approver');
appNew.addQuery('document_id',current.getValue('sys_id'));
appNew.addQuery('state','approved');
appNew.query();
if(appNew.next()){
template.print('Approver Name is : '+appNew.approver.getDisplayValue());
}
Please correct me if I'm wrong. It is not giving any approver name.
Regards,
Nivedita