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

Yash Agrawal1
Tera Guru

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

Jaspal Singh
Mega Patron
Mega Patron

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}

Ashutosh Munot1
Kilo Patron
Kilo Patron

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

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