How to add past approvers to an notification using an email script

Peter Williams
Kilo Sage

hey everyone,

going onto my issues i am facing with my expense form.

I need to include all past Approvers onto the email notification.

 

On the expense form i have a reference fields called Approvers. In my Workflow i was able to get that approver selected in the form to be the approver of the request. 

Once the approver has approve the request another email notification is sent to the finance dept. 

I need to include the Approver who approve the request along with the date of which it was approved.

 

How can i do this?

 

i added this to my script but it doesnt seem to work

var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
while(gr.next()){
template.print('Details');
template.print(gr.getValue("approver") + " "+gr.getValue("state"));
}

2 ACCEPTED SOLUTIONS

Harshal Aditya
Mega Sage
Mega Sage

Hi @Peter Williams ,

 

Hope you are doing well.

 

Please try below script -

 

var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('document_id', current.sys_id);
gr.addQuery("state","approved"); // Filter out only approved record if you want all comment this line
gr.query();
while(gr.next()){
template.print('Details');
template.print(gr.getDisplayValue("approver") + " "+gr.getValue("state") +"Approved Time "+gr.getDisplayValue("sys_updated_on"));
}

 

Please mark this response as correct or helpful if it assisted you with your question.

Regards,
Harshal

View solution in original post

Harshal Aditya
Mega Sage
Mega Sage

Hi @Peter Williams ,

 

template.print(gr.getDisplayValue("approver") + " "+gr.getValue("state") +"Approved Time "+gr.getDisplayValue("sys_updated_on")+" "+gr.comments.getJournalEntry(1));

gr.comments.getJournalEntry(1) will fetch you the latest comment

 

Regards,

Harshal

View solution in original post

4 REPLIES 4

Harshal Aditya
Mega Sage
Mega Sage

Hi @Peter Williams ,

 

Hope you are doing well.

 

Please try below script -

 

var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('document_id', current.sys_id);
gr.addQuery("state","approved"); // Filter out only approved record if you want all comment this line
gr.query();
while(gr.next()){
template.print('Details');
template.print(gr.getDisplayValue("approver") + " "+gr.getValue("state") +"Approved Time "+gr.getDisplayValue("sys_updated_on"));
}

 

Please mark this response as correct or helpful if it assisted you with your question.

Regards,
Harshal

Thank you that did it

Is there a way to get the Approved Comments also?

Harshal Aditya
Mega Sage
Mega Sage

Hi @Peter Williams ,

 

template.print(gr.getDisplayValue("approver") + " "+gr.getValue("state") +"Approved Time "+gr.getDisplayValue("sys_updated_on")+" "+gr.comments.getJournalEntry(1));

gr.comments.getJournalEntry(1) will fetch you the latest comment

 

Regards,

Harshal

amazing thank you