We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

How to avoid using for each in flow designer ?

kiran kumar m1
Tera Contributor

image (9).pngimage (8).pngimage (7).pngI have a catalog in which , multiple users request a software or single user requests multiple softwares ,
in the flow i want a managers approval , if suppose three users were selected , then it should create three manager approvals , for which i did the lookup in sys_user table , there in the condition I have written a script 

"var uid=fd_data._1__get_catalog_variables.requested_for2;
var query = "sys_idIN" + uid;
return query;"

this script will fetch the sys_ids from the list collector type variable , then I have written a for each which will take each sys_id and it will create  a approval record for it 

once this approvals are created , when each approval is approved I want a task should be created , 
but here as I am using for each , its picking a random sys_id / picking in ascending order ,
until and unless i approve the approvals in order the next task generation is not happening as expected is there any way I can overcome this 




 
 
 

 

 

 

5 REPLIES 5

Rafael Batistot
Kilo Patron

Hi @kiran kumar m1 

 

The issue is that For Each runs sequentially, so the flow waits for each approval in its iteration order. If approvals happen out of order, task creation is delayed.

 

Create all approvals first, then use a Flow or Business Rule on sysapproval_approver to create the task when each approval is approved. This allows tasks to be created regardless of the approval order.

 

If this response was helpful, please mark it as Helpful and, if applicable, as Correct.
This helps other users find accurate and useful information more easily

Ankur Bawiskar
Tera Patron

@kiran kumar m1 

you want sequential approval or parallel approval?

You can use scripted flow approval

Scripted Approvals in Flow Designer with Flow Variables 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Hi @Ankur Bawiskar I want parallel approval

@kiran kumar m1 

then use script and send approval to all users at once

Scripted Approvals in Flow Designer with Flow Variables 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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