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.

how to get approval request record in email script

Developer3
Tera Expert

When a knowledge article is sent for approval, i am preparing a notification (event triggered and on knowledge table) to send to approver. That event parm1 has the approver sys id.

In the email message, i have the below line:

Click here to view Approval Request

When the user clicks here, approval record has to open. Can anyone help me in writing the email script for this.

1 ACCEPTED SOLUTION

Dubz
Mega Sage

You should be able to get this in a mail script:

var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('document_id', current.getUniqueValue());
gr.query();
if(gr.next()){
var link = '<a href="sysapproval_approver.do?sys_id=' + gr.getUniqueValue() + '">here</a>'
template.print('Click ' + link + ' to view the Approval record');
}

View solution in original post

2 REPLIES 2

Dubz
Mega Sage

You should be able to get this in a mail script:

var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('document_id', current.getUniqueValue());
gr.query();
if(gr.next()){
var link = '<a href="sysapproval_approver.do?sys_id=' + gr.getUniqueValue() + '">here</a>'
template.print('Click ' + link + ' to view the Approval record');
}

Gab
Tera Expert

Hi i know that this is an old post, but i noticed that if you use a group as an approver this will insert a multiple records in sysapproval_approver table. Now, how can you get the specific record that has been approved/reject?

The code you have given is working perfectly, but it only gets the latest approval record, and not the record which being approved/reject.