Call us today to see how we can help you be at your best.
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 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 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://flow.microsoft.com/en-us/documentation/limits-and-config/
Sign up today to receive our monthly newsletter with tips, Microsoft funding availabilites, upcoming events and industry news.
Ready to celebrate the year with us?
Softlanding is hosting their third annual Open House party at our downtown office. Join us for an evening of cocktail party hors-d'oeuvres, drinks, live music with I M U R, prize draws, and photo booth fun!
Sign-up to our monthly newsletter for valuable insights, workshops/events and funding available for your next project!