Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Flow Designer / Do the Following Until

abdelkadergh
Mega Contributor

I’m trying to loop a series of actions until a record meets certain criteria. What are some best practices for using “Do the Following Until” to avoid infinite loops and ensure performance remains stable?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@abdelkadergh 

my thoughts

Best Practice Description
Define Clear Exit Conditions Set a specific, achievable condition to exit the loop.
Limit Iterations Ensure the loop does not exceed the default max (usually1000 iterations).
Use Wait Actions Wisely Set reasonable wait durations and attempt limits for "Wait" actions.
Monitor and Log Progress Add logging to track loop progress and aid debugging.
Use Exit and Skip Loop Actions Exit or skip loop iterations using dedicated actions.
Avoid Recursive/Nested Loops Refactor logic to avoid nested or recursive loops.
Prevent Unintended Triggers Ensure the flow does not trigger itself or cycle with other flows.
Optimize Data Access Use GlideAggregate or limits for efficient data queries in loops.

sharing links for references

https://www.linkedin.com/posts/muhammad-faizan-shahid-8b7548219_servicenow-flowdesigner-datastream-a... 

Exit and Skip Loop in Flow Designer 

Do the following until flow logic 

💡 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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@abdelkadergh 

my thoughts

Best Practice Description
Define Clear Exit Conditions Set a specific, achievable condition to exit the loop.
Limit Iterations Ensure the loop does not exceed the default max (usually1000 iterations).
Use Wait Actions Wisely Set reasonable wait durations and attempt limits for "Wait" actions.
Monitor and Log Progress Add logging to track loop progress and aid debugging.
Use Exit and Skip Loop Actions Exit or skip loop iterations using dedicated actions.
Avoid Recursive/Nested Loops Refactor logic to avoid nested or recursive loops.
Prevent Unintended Triggers Ensure the flow does not trigger itself or cycle with other flows.
Optimize Data Access Use GlideAggregate or limits for efficient data queries in loops.

sharing links for references

https://www.linkedin.com/posts/muhammad-faizan-shahid-8b7548219_servicenow-flowdesigner-datastream-a... 

Exit and Skip Loop in Flow Designer 

Do the following until flow logic 

💡 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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader