Approval Rejection is not working

Community Alums
Not applicable

Hi All, 

 

Having a requirement triggering a multiple approval and after approvals task provision. 

for that we tried using flow designer and workflow in flow designer we were using common subflow for manager approval after that tried to use the workflow for multiple approvals after approvals finally task provision.

 

But in the rejection case the workflow is not working as expected(if all the approvals are rejected it should return reject value. but its getting approved value and triggering task.

 

chanti1_0-1681222016090.png

 

 

Wait Condition :

checkApproval();
function checkApproval() {
var grTask = new GlideRecord('sysapproval_approver');
grTask.addQuery('sysapproval', current.sys_id);
grTask.addQuery('state','requested');
grTask.query();
if(grTask.hasNext()){
answer = false;
}
else{
answer = true;
}
}

 

If condition :

answer = ifScript();
function ifScript() {
var app_count = 0;
var approval = new GlideRecord("sysapproval_approver");
approval.addQuery('sysapproval='+ current.sys_id +'^state=rejected');
approval.query();
var app_count = approval.getRowCount();
if(app_count == 😎 {
return 'yes';
}
else {
return 'no';
}
}

 

Need suggestion. 

 

 

 

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Community Alums 

so you want to wait till all approvals are rejected?

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

Community Alums
Not applicable

@Ankur Bawiskar 

if the triggered all approvals are rejected then it should pass value Rejected.

chanti1_0-1681223603122.png

 

But in current workflow its returning approved at the end and triggering the task. even if the approvals are rejected.

 

@Community Alums 

Would you mind closing your earlier questions by marking appropriate response as correct so that it helps future readers?

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

Community Alums
Not applicable

@Ankur Bawiskar 

Any suggestion on this current workflow execution. 

after subflow manager approval we used a workflow for multiple option selection group approvals. 

if Script :

answer = ifScript();
function ifScript() {
var app_count = 0;
var approval = new GlideRecord("sysapproval_approver");
approval.addQuery('sysapproval='+ current.sys_id +'^state=rejected');
approval.query();
var app_count = approval.getRowCount();
if(app_count == 10) {
return 'yes';
}
else {
return 'no';
}
}

 

through this script it returning value approved. because the manager approval is considering as approved, hence triggering the task. 

it should not be. 

only the group approvals need to check based on that approval it should return value.