I have a client who is heavily using a Word template in flow to generate reports upon completion of a record in their system.  This can mean the same template is requested by multiple users at once and has led to the flow failing periodically and seemingly at random.  The best explanation I have come up with is that for a split second, the template is “checked out” of its location on SharePoint and when a second flow tries to populate the template simultaneously, you get an error because the template is momentarily not accessible to flow.  We are creating so many documents per day this way that I was getting a few flow failures per day and when I went in and manually resubmitted them, they typically succeeded without issue.  A few times, more than one resubmission was needed but they eventually were able to get access to the needed template and succeed.

This led to the below technique that will keep retrying the “Populate template” block until it succeeds or fails after 10 attempts.

In brief, the technique is to increment 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’. Configure Run After to ‘has failed’.  Inside the Try control, increment the Retry variable by 1 and set a condition block to email you if the ‘Retry’ variable makes it to 10.

Power Automate Scope Control

Power Automate Scope Control

Step 4: Insert a second scope control to run after ‘Try’ is successful or skipped.  Inside it set the Retry variable to 10.  This functions as an off ramp for the repeating logic and allows your flow to continue if/when the template fires correctly.

Power Automate Scope Run After

Bonus Step!

In your failure alert email, if you add this expression, your 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’], ‘/flows/’, workflow()[‘name’], ‘/runs/’, workflow()[‘run’][‘name’])}

>Go To Record</a><br></p>

Power Automate Failure Alert Email

Get to Know Power Automate

While Microsoft Power Automate is not only free for many applications and has the potential to make your business work faster, getting it set up can often be overwhelming. With hundreds of connections, the process of building, testing, and customizing the connectors that work for your business might be more complex than you initially expect.

At MIBAR, we have the experience and expertise to set up the entire Microsoft Power Platform including Microsoft Power Automate, Power BI, and PowerApps for your company. Get to know more about the work we do, read our Microsoft Power Automate case study, and contact us for more information.