Same user cannot approve change request again in 2nd level approver

Harsha Pandey
Tera Expert

Hi,

Customer requirement is that same user should not be able to approve change request again or I can say in 2nd level approval.

I had gone through community and found out post https://servicenowguru.com/scripting/business-rules-scripting/prevent-redundant-approval-requests-servicenow/

I tried this with one more condition as current.getTableName('change_request') as I need it to to run for change_request but did not work.

Please help me out!!

1 ACCEPTED SOLUTION

Hi,

your requirement is to make it work only for change_request table and hence it would only run for those approvals

Won't impact any other table

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

15 REPLIES 15

Chin4
Tera Expert

Hi all,

 

I modified a script found on community to prevent an approver of change request from approving 2 times. This applies to the same approver from different group and on the same authorization stage.

 

Here is the BR script:

Table: sysapproval_approver

When: before , insert/update

Order: 300

var gr = new GlideRecord('sysapproval_approver'); //Indicate the table to query from

gr.addQuery('sysapproval', current.sysapproval);
gr.addQuery('approver', current.approver);
gr.addQuery('state', 'approved');
gr.query(); //Execute the query

if (gr.next()) { //While the recordset contains records, iterate through them

//Do something with the records returned
gs.addInfoMessage("Only 1 approval is allowed per approver!");
gs.addInfoMessage("2nd approval aborted for " + current.approver.name);

//current.setAbortAction(true);
current.state= 'not_required';
}

 

Good luck.

 

Chin4