In Focus Resource Center > Insights

How to Automatically Retry a Flow in Microsoft Power Automate

By Andrew Yoder .

Some Power Automate users heavily rely on a Word template in flow to generate reports upon completion of a record in their system. Multiple users may be requesting the same template at once, which leads to the flow failing periodically, seemingly at random. The best explanation our team gathered is that for a split second, the template is “checked out” of its SharePoint location. Therefore, when a second flow simultaneously tries to populate the template, it results in an error because the template is momentarily not accessible to flow. When many documents per day are created this way, multiple flow failures per day will result. However, if users manually resubmit them, they typically succeeded without issue. Occasionally, it will take multiple resubmissions, but eventually, access to the required template is available, and the flow is successful.

Steps to automatically retry a Power Automate flow

As a result, our team developed the following technique, which keeps retrying the “Populate template” block until it succeeds or fails after 10 attempts. In brief, the technique increments a variable to count to 10 retry attempts but only if that block fails.

Step 1: Initialize an integer variable called “Retry” with a value of zero.

Power-Automate-Initialize-Retry

Step 2: Right above the “Populate a Microsoft Word template” block, insert a “Do Until” loop. Set it to go until retry is equal to 10.

Power-Automate-Do-Until

Step 3: Insert a scope control called “Try.” Under “’Try’ should run after,” check the box that corresponds with “has failed.” Inside the “Try” control, increment the retry variable by one, and set a condition block to email you if the retry variable makes it to 10.

Power-Automate-Scope-Control

Power-Automate-Scope-Control-2

Step 4: Insert a second scope control to run after “Try” is successful or skipped. Inside this control, set the retry variable to 10. This will function as an off ramp for the repeating logic and will allow the flow to continue when the template fires correctly.

Power-Automate-Scope-Run-After

Bonus Step: In the failure alert email, if the following expression is present, the email will include a hyperlink back to the exact flow that failed.

<p>Link:

<a href="@{concat(‘https://emea.flow.microsoft.com/manage/environments/’,workflow()[‘tags’][‘environmentName’],">Go To Record</a>

</p>

Power-Automate-Failure-Email

While many applications for Microsoft Power Automate are free and have the potential to make your business work faster, getting the platform set up can often be overwhelming. With hundreds of connections, the process of building, testing, and customizing the connectors that work for your business may be more complex than initially expected.

How Citrin Cooperman can help

Citrin Cooperman’s Digital Services Practice has the experience and expertise to help set up the entire Microsoft Power Platform, including Microsoft Power Automate, Power BI, and PowerApps, so your company can achieve its strategic vision. To learn more about Microsoft Power Automate and the ways in which our team can assist your business, reach out to your Citrin Cooperman advisor or Andrew Yoder at sales@citrincooperman.com.

Our specialists are here to help.

Get in touch with a specialist in your industry today. 

By your submission of information in this form, you are consenting to our collection, use, processing and storage of your information in accordance with Citrin Cooperman’s privacy policy. If you have questions regarding our use of your information, please send an e-mail to privacy@citrincooperman.com