Is it possible to enforce unique approvers across different approval levels?

srinija_itom
Giga Guru

Hello everyone, 

 

We have a multi-level approval process for Normal changes, ranging from Level 1 to Level 3. If a user belongs to both Group A and Group B, and they approve a change at Level 1, we want to prevent the same user from approving the change again at Level 2.

 

Is it possible to enforce unique approvers across different approval levels to ensure that the same individual does not approve the same change more than once? Please advise. 

 

Regards, 

 

Srinija

2 ACCEPTED SOLUTIONS

Rafael Batistot
Tera Sage

Hi @srinija_itom 

 

May you create a Before Insert/Before Update Business Rule on the sysapproval_approver table that checks if the user trying to approve at the current level has already approved the same Change Request at a previous level.

 

Example logic:

 

(function executeRule(current, previous /*null when async*/ ) {

// Only run on approval actions
if (current.state == 'approved') {
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sysapproval); // same Change
gr.addQuery('approver', current.approver); // same user
gr.addQuery('sys_id', '!=', current.sys_id); // exclude current record
gr.addQuery('state', 'approved');
gr.query();

if (gr.next()) {
// Already approved at another level
gs.addErrorMessage("You have already approved this Change at another level. Another approver must review.");
current.setAbortAction(true);
}
}

})(current, previous);

This prevents a user from approving multiple times, regardless of which group/level they’re in.

 

View solution in original post

srinija_itom
Giga Guru

Hey @Rafael Batistot

 

The above solution worked! Thank you so much for the advise!

 

Regards, 

 

Srinija

View solution in original post

2 REPLIES 2

Rafael Batistot
Tera Sage

Hi @srinija_itom 

 

May you create a Before Insert/Before Update Business Rule on the sysapproval_approver table that checks if the user trying to approve at the current level has already approved the same Change Request at a previous level.

 

Example logic:

 

(function executeRule(current, previous /*null when async*/ ) {

// Only run on approval actions
if (current.state == 'approved') {
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sysapproval); // same Change
gr.addQuery('approver', current.approver); // same user
gr.addQuery('sys_id', '!=', current.sys_id); // exclude current record
gr.addQuery('state', 'approved');
gr.query();

if (gr.next()) {
// Already approved at another level
gs.addErrorMessage("You have already approved this Change at another level. Another approver must review.");
current.setAbortAction(true);
}
}

})(current, previous);

This prevents a user from approving multiple times, regardless of which group/level they’re in.

 

srinija_itom
Giga Guru

Hey @Rafael Batistot

 

The above solution worked! Thank you so much for the advise!

 

Regards, 

 

Srinija