When you run this Flow, it’ll will only run once before completing. Back on the dashboard, the run’s status shows it Succeeded. So why does it only run one time instead of the actual number of times?
Goal: A PowerApps button kicks off a Microsoft Flow and you want the flow to run daily, or at least 24 hours apart.
Use case: A vacation status process where you need to send a record system several daily reminders. This could be done manually, but it can be bothersome, inaccessible, or simply impossible.
Easy-to-use loop functions, like those familiar in many programming languages, do not exist in PowerApps or Flow.
In PowerApps, there is only one option: ForAll. To use this loop, you must first store parsed data into a collection, then, and only then, can you iterate through each piece of data. Even then, the same actions are applied to every item. For example, storing words from a form and translating all of them to French. Sometimes storing the data isn’t possible though, or at least not without a great deal of effort.
In Flow, it’s slightly better. You have two choices: an Apply to Each action or a Do Until action.
Just like PowerApps, the Apply to Each action requires a collection of items, which has the same limitations. So realistically, that only leaves one option – the Do Until action.
The Do Until action compares two values and loops until the preset condition is met. Expanding the Change limits dropdown, we see more specifications for Count and Timeout.
This is a simple flow with a Do Until and Delay.
It is triggered by PowerApps, then creates a counter for the Do Until loop, which will run six times. Each iteration will wait a day before sending out an email and increase the counter by one.
When you run this Flow, it’ll only run once before completing. Back on the dashboard, the run’s status shows it Succeeded. So why does it only run one time instead of six?
Note: there is almost no documentation regarding the Do Until action in general. This is all Microsoft has to say:
And there is nothing on how to use the action or how to change its parameters, such as the advanced mode or any of the limits. Since Flow is just a presentation layer on top of Logic Apps, all the documentation can be found in the Logic Apps documentation. Looking at the response body in JSON format from a generic Logic App HTTP request, we can see corresponding keys – count and timeout.
From that documentation, we know the Flow stops if at least one of three conditions are met – on completion, after running several iterations, or after some time. Since Timeout uses ISO 8601 notation, we can change the timeout to P1DT1M, so that the action doesn’t time out due to inactivity from the Delay action.
Running it again, the Do Until runs twice and completes. Turns out, the timeout isn’t based on inactivity, but actual run time. So, if we want Flow run for six days, we’ll have to change the timeout to be more than six days – for example, P1M.
However, keep in mind of the upper limits – 30 days for timeout and 5000 for count. More on numerical limits here: https://docs.microsoft.com/en-us/power-automate/limits-and-config
Learn More about Softlanding
Softlanding helps organizations be their best by providing technology solutions and services that make them more productive. Softlanding specializes in Microsoft enterprise technology platforms, leveraging a combination of cloud, on-premises and hybrid configurations to increase productivity from the data center on out to end business users. Areas of specialty include end-to-end SharePoint services, Microsoft Enterprise Infrastructure and Managed IT Services.