Change management Workflow wait for condition script

keerthana10
Tera Contributor

Hi Experts, 

In the change management workflow, I am using an Approval Coordinator. Under the Approval Coordinator, I have added 2 child approvals. I want the state to move to the next state only when both child approvers have approved. I created a wait-for-condition script, but it's not working. The state moves to the next state when only one child activity approver is approved. How can I resolve this?"

 

script:

 

var approvalGR = new GlideRecord('sysapproval_approver');
approvalGR.addQuery('sysapproval_approver', current.sys_id);
approvalGR.query();

var allApproved = true;

while (approvalGR.next()) {
  var state = approvalGR.getValue('state');
  if (state != 'approved' ) {
     allApproved = false;
    break
  }
}
allapproved=true;
 
2 REPLIES 2

J Siva
Tera Sage

Hi @keerthana10 
Have you tried using "All child activities to be approved" condition?
Also check the status of the approval field in CRQ after actioning the first approval.
If possible could you please share the snap of your flow.

Hi @J Siva 

yes, i am using this "All child activities to be approved" condition.

After first approval its moved to next state.