One of its most useful features in the flow is ‘Do Until’ loop. It allows you to repeat actions until a certain condition is met. This makes it ideal for scenarios where
- you need to wait for data to change,
- a process to complete, or
- a status to update before proceeding.
In this article, we’ll dive deep into mastering the ‘Do Until’ loop in Power Automate, explaining its structure, how to use it, and tips to make the most of it.
What is the ‘Do Until’ Loop?
The ‘Do Until’ loop is an action in Power Automate that allows you to perform a series of actions repeatedly until a specified condition met.
Key Features of the ‘Do Until’ Loop:
- Condition-Based Execution: The loop continues until the specified condition evaluates as true. Once the condition is met, the loop stops, and the flow proceeds with the next actions.
- Repeat Actions: You can add multiple actions inside the loop that will be executed each time the loop runs. T
- Timeouts: The ‘Do Until’ loop comes with a timeout option. You can set the number of iterations for the loop to run. This ensures the loop does not run indefinitely.
Configure the ‘Do Until’ in Power Automate
Inside the Do Until action, click Show All to reveal the advanced parameters where you can modify the loop settings.
- Count: This parameter determines the number of times the loop will run before it stops. The loop will either stop when the condition is met or when it reaches the specified count value. The maximum limit of count value, we can set is 5000.
- Timeout: This property allows you to stop the loop if the condition isn’t met within a specified time frame. You can provide the timeout duration in ISO 8601 format, which defines the maximum time the loop should run before halting.The maximum limit of timeout value is P30D or P1M (30 days or 1 month).
Examples:
- P2D – 2 day (where “D” stands for day)
- PT2H – 2 hour (where “T” represents time, and “H” stands for hour)
- PT40M – 40 minutes
- P5DT4H30M – 5 days, 4 hours, and 30 minutes
Default configuration:
- Counts: By default, it will show count as 60 which means it will loop 60 times.
- Time Out: By default, Timeout shown as PT1H. It means loop will run till 1 hour.
Note: If either the Count or Timeout is reached, the loop will exit, even if the condition is not met. Therefore, you should plan your iterations to ensure the condition is satisfied within the maximum specified timeout or count.
How to use do until action please take help from this link.
Best Practices for Using the ‘Do Until’ Loop
- Always use the Delay action to control the timing of your iterations. For example, if you set the count to 60 and the delay to 1 minute, the loop will iterate every minute.
- Avoid Long Loops: While the ‘Do Until’ loop is powerful, avoid setting long timeouts or excessive iterations that might waste resources or cause delays in the flow. Instead, aim for a short wait time (e.g., 1-2 minutes) and make sure your flow exits after a reasonable timeout.
- Error Handling: Add error-handling actions to manage situations where the loop doesn’t exit successfully or an unexpected error occurs. For instance, you can send a notification if the timeout is reached without meeting the condition.
- Monitor and Test: After setting up your ‘Do Until’ loop, monitor its performance. Check if the loop is executing too often or taking too long to complete. Testing the flow with different conditions will help you fine-tune the setup.
Conclusion
The ‘Do Until’ loop in Power Automate is a flexible and powerful tool for automating repetitive tasks that depend on a condition. By understanding how to set up and configure this loop, you can create highly efficient workflows that wait for the right moment to proceed.
With the ability to set conditions, iterate actions, and implement timeouts, mastering the ‘Do Until’ loop gives you more control over your automation processes. Whether you’re waiting for data to become available, a task to be completed, or an event to be triggered, this loop can significantly improve the flexibility and responsiveness of your flows.