How to set other approver state to 'No longer required' if one Approver approved the request

Burugupalli Dha
Tera Contributor

Can anyone please help in how to write the code in the below BR for the below scenario?


var grAppr = new GlideRecord('sysapproval_approver');
grAppr.addQuery('sysapproval', current.sysapproval);
grAppr.addQuery('u_injectorss',false);
grAppr.query();
while (grAppr.next()) {

    // help me with the code

}

There are total 3 approvals. If one approval state is approved the other 2 approval states should be set to 'No Longer Required'.

find_real_file.png

1 ACCEPTED SOLUTION

Hajar BENJAHHAR
Mega Sage

Hello, 

You have to create an after business rule : 

find_real_file.png

Script : 

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

    var grAppr = new GlideRecord('sysapproval_approver');
    grAppr.addQuery('sysapproval', current.sysapproval);
    grAppr.addQuery('u_injectorss', false);
	grAppr.addQuery('approver', '!=', current.approver);
    grAppr.query();
    while (grAppr.next()) {
        grAppr.state = "not_required";
		grAppr.update();
    }

})(current, previous);

Result : 

find_real_file.png

View solution in original post

5 REPLIES 5

Thanks !!