Wait for approvals condition in flow designer

ClareM
Tera Expert

We are converting our workflows to flow designer but I am struggling to replicate this scripted wait for condition which waits for an approval to be rejected or all approvals to be approved

 

To provide some context there are numerous concurrent and sequential approvals - to provide visibility of subsequent approvals we first lookup the required approvers and set these as not yet requested then loop through and set those with iterator 1 as requested, then iterator 2 etc.

 

Can anyone advise how best to replicate this in Flow Designer?

 

var sysAppCheck = new GlideRecord('sysapproval_approver');
var reqCount = 0;
sysAppCheck.addQuery('sysapproval', current.sys_id);
sysAppCheck.query();
while(sysAppCheck.next()){
if(sysAppCheck.state == 'rejected'){
workflow.scratchpad.appOrRej = 'rejected';
reqCount++;
answer = true;
break;
}
 
if(sysAppCheck.state == 'requested'){
reqCount++;
answer = false;
}
}
 
if(reqCount == 0){
workflow.scratchpad.appOrRej = 'approved';
answer = true;
}
1 ACCEPTED SOLUTION

ClareM
Tera Expert

I solved this with a business rule to set open approvals as no longer required if an approval changes to rejected, then the flow continues as required

View solution in original post

4 REPLIES 4

Dnyaneshwaree
Mega Sage

Follow below steps:
1. lookup on "sysapproval_approver" table. and map required fields like sysid.
2. from 3 dots in right create flow variable - count.
3. set flow variables - count = 0 in flow.
4. Add if condition - if lookup reference state = rejected.
5. update record of the whatever table you need for "
workflow.scratchpad.appOrRej = 'rejected';" for this. and increase the count.

6. else conditions - update records and increase count.

Dnyaneshwaree_0-1718111553497.png

If my answer helps you please mark as accepted/helpful by adding thumb in bottom of my post.

Thank You!!

 

Please accept my solution if it works for you and thumps up to mark it as helpful.
Thank you!!

Dnyaneshwaree Satpute
Tera Guru

Thanks for the reply. I'm struggling with the Wait for condition as this requires a single record as an input whereas I want to wait for all records to be approved (state not requested) before continuing unless a record is rejected - in which case end flow

Dnyaneshwaree
Mega Sage

Use "For each" activity for required table and conditions to check all the required records then end the flow.

Please accept my solution if it works for you and thumps up to mark it as helpful.
Thank you!!

Dnyaneshwaree Satpute
Tera Guru

ClareM
Tera Expert

I solved this with a business rule to set open approvals as no longer required if an approval changes to rejected, then the flow continues as required