logo

NJP

How to Run a Flow Loop n Times in ServiceNow Using ‘Do the Following Until’

New article articles in ServiceNow Community · Jan 05, 2026 · article

Have you ever encountered a customer requirement where you need to run a loop in a Flow for n number of times? Here’s an easy way to achieve this using the “Do the Following Until” logic + Flow Variables in Flow Designer:

  1. Create a Flow Variable
    • Type: Integer
    • Initialize it with value 0 using the “Set Flow Variables” flow logic.
  2. Add “Do the Following Until” Logic
    Inside this block:
    a) Add your required flow actions.
    b) Use “Set Flow Variables” again to increment the count by 1 using script .
  3. Set the Condition
    • Until count = 3 (or any number you need).

This way, your flow will execute the actions 3 times. Try this approach and enhance your flows to handle looping requirements efficiently!

Here is the working approach

run flow 3 times based on flow variable.gif

View original source

https://www.servicenow.com/community/workflow-automation-articles/how-to-run-a-flow-loop-n-times-in-servicenow-using-do-the/ta-p/3460322