Good day.
I have a series of Power Automate flows for our Survey123 platform. Many of the Survey123 reports that are submitted are time sensitive and are required in order to proceed with other task(s) within the company.
There are times that a flow fails to run and I am not aware of it until management complains that they haven't seen a specific PDF report.
Trying to come up with a solution that I am notified (E-mail) if a flow fails and/or a nightly E-mail log/report showing the successful completion of all flows and any failed/error flows.
Any guidance would be appreciate.
Scopes! You want Scopes.
They are a little unassuming, but super important for a healthy flow.
First, we need to understand how a fail works in Power Automate.
In this scenario, we will not trigger our step E. That is because Step B failed, and everything after it was actually "Skipped". That is where Scopes come in. If anything inside a Scope fails, the entire Scope fails.
As I've already mentioned, scopes. You want to put your entire flow into one scope, and your error handling into a second scope. The only exceptions being: 1) Initialize Variable cannot be added to a scope (super annoying), and 2) Flow Trigger (this one makes more sense).
This type of setup is normally referred to as "Try" and "Catch", where Try is your workflow, and Catch is your error handling.
When you do this type of setup, you need to guide Power Automate a little. When your error handling executes successfully (as it should), your flow will actually register as a success. This makes looking at your flows in Power Automate annoying. To solve this, always ensure the final step of your Catch is a "Terminate" (set to either Fail or Cancelled depending on your needs -- I go with Fail because I use Cancelled for other things).
It really depends on your needs. What you see above is a relatively "normal" Catch that I use. In fact, I probably have a good couple hundred flows with this general set-up.
When something goes wrong, you will want to go to that flow to assess the problem and potentially make a correction. Add this to the email (as an expression):
concat('https://emea.flow.microsoft.com/manage/environments/', workflow()['tags']['environmentName'], '/flows/', workflow()['name'], '/runs/', workflow()['run']['name'])Here is what it looks like in the flow:
You can pretty it up and add more content if you want. But this is the absolute minimum you need.
In case you want to reset other databases, here is how I use contions...
Step 1: Initialize Variable
Just make a boolean and set it to false (technically not required to set it to false, but it helps keep things simple for future you).
Step 2: Set Variable
Do this immediately after the thing you are going to reset. In this example, I set if after my SharePoint Create Item.
Step 3: Condition within the Catch
The condition ensures you don't try to reset something that doesn't need to be reset. As simple as that.