Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Need to get approver name.

niveditakumari
Mega Sage

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 

 

1 ACCEPTED SOLUTION

Hi Nivedita,

 

 

Replace approv.query(); with below in your code once.

approv.addQuery('state','approved');

approv.orderByDesc('sys_upated_on');

approv.query();

View solution in original post

17 REPLIES 17

niveditakumari
Mega Sage

Hi, 

 

I have written this code and it is retrieving all approval name but i need only user who has approved it. 

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

// Add your code here
var appr_list = [];
var approv = new GlideRecord('sysapproval_approver');
approv.addQuery('document_id',current.sys_id);
approv.query();
gs.log('entered');
while(approv.next())
{
gs.log('entered in while loop');
appr_list.push(approv.approver.getDisplayValue());
}

template.print(appr_list);

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

 

Please help me with this. 

 

Regards, 

Nivedita 

Hi Nivedita,

 

 

Replace approv.query(); with below in your code once.

approv.addQuery('state','approved');

approv.orderByDesc('sys_upated_on');

approv.query();

Hi Jaspal, 

 

It is working as expected. 

Thank you so much for your help. 

 

Regards, 

Nivedita