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

Musab Rasheed
Tera Sage
Tera Sage

Hi,

First you should change this in your workflow, see Group Approval activity in workflow and make sure these options are selected, generally when someone approves then others state moves to 'No longer required' automatically. Mark my answer as correct if that helps.

find_real_file.png

Please hit like and mark my response as correct if that helps
Regards,
Musab

dmathur09
Kilo Sage
Kilo Sage

Hi,

In your approval activity in the workflow, select the wait for "First Response from anyone"

find_real_file.png

Regards,

Deepankar Mathur

Can you pls help in script without updating in the workflow?

 

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