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.
@abureaux It is very obvious that you are way more advanced compare to me and your knowledge super-seeds me 10-fold and your flow(s) and process(s) are most likely way more complexed compared to my simple Survey123 report creation and e-mail flows.
With that said, I went very basic and elementary in my flow(s) and just created a parallel branch with the "Run After" settings of successful or failed. Yeah, no duh ah?
One of the key factors that leads to a failed flow in Power Automate for me is when there is an ESRI outage affecting AGOL and Hosted Feature Layers (something that those above me that rely on these reports do not quite understand). If there is an unknown factor causing an interruption with AGOL and the feature layers that power the Survey123 process, I have a way of being notified instantly.
Perhaps someone else that shares my limited knowledge of Power Automate and coding, could also find this helpful.
Again @abureaux Always appreciate your expertise.
Depending on how you currently do error handling and recovery, you may wish to do something similar to me.
Basically...
I'm sure I made this sound harder than it really is. But this is (generally speaking) the best process automation solution I've found for this work. It ensures 1) nothing is missed, and 2) if there is an error, an automatic re-try occurs.
@abureaux Thanks for your post, this is quite amazing! I learned a few cool things here. It is a great candidate for a blog if you haven't already considered writing one!