Select to view content in your preferred language

Power Automate - Re-Establish Connection

609
13
07-23-2025 08:07 AM
ModernElectric
Frequent Contributor

Good Morning:

I have a large number of Survey123 forms created with individual Power Automate Flow(s) that automatically create a PDF printed report and emails it to selected personnel who need it. 

It has become a trend in recent months that I get a complaint from a Superintendent that they did not receive a specific report after their foreman said it was submitted. Investigating the flow(s), they fail and I have to go back in and re-set up the connection, re-establishing the webhook that is created when I build the flow. 

I need some guidance on what I need/should be doing to prevent this from continuing to happen. 

0 Kudos
13 Replies
CodyPatterson
MVP Regular Contributor
ModernElectric
Frequent Contributor

@CodyPatterson 

Thank you for the feedback and guidance. I will look into the Quick Tip to see how I can benefit

0 Kudos
abureaux
MVP Frequent Contributor

Connection needs to be refreshed once every 2 weeks. I have a reminder to do it every week, and track the refreshes in SharePoint to avoid such an issue.

Also, you can attach error handling to your flows, so if they do fail, you get notified right away and can investigate. Let me know if you'd like info on this (it's generally pretty easy).

ModernElectric
Frequent Contributor

@abureaux 

Yes, I would appreciate info on setting that up in my existing flows. This way, I can be more proactive in catching a failed flow before being yelled at for them not working when someone needs the final reports. 

Power Automate use to, at one time, send me an email notification when a flow failed, but have not seen them in awhile.

0 Kudos
abureaux
MVP Frequent Contributor

At the most basic level, you need three things:

  • Scopes
  • Run After
  • Send an email

Here are the steps:

1. Make two scopes and put all your flow steps into the first Scope. The only real exceptions here are Initialize Variables and the Flow's trigger, neither of which can go into a scope--you can ignore these steps. As for naming the Scopes, that is up to you and it technically doesn't matter; however, most people will refer to this as "Try" and "Catch". Your flow should now look similar to below:

abureaux_1-1753290507565.png

2. Click the ellipses (...) for the second Scope > click "Configure run after" > uncheck "is successful" and check "has failed" > click Done. It should look like this:

abureaux_0-1753290368864.png
You will now notice a red arrow between the two steps. That indicates a different "run after", which is what you want.

abureaux_2-1753290621883.png

3. Finally, within the second Scope add your error handling steps. At minimum, I recommend two things: A) Send an email, and B) Terminate (set it to "Failed").

3A) The email should go to the flow's owner, and the subject should be something that (presumably) you will recognize. Feel free to customize this any way you want.

But the most important part is the code below. This code will create a link which will take you to the flow that failed. This saves tons of time! To add the code: Click into the Send an email's "Body" field > in the popup, click "Expression" > paste the code as-is > click OK. 

concat('https://emea.flow.microsoft.com/manage/environments/', workflow()['tags']['environmentName'], '/flows/', workflow()['name'], '/runs/', workflow()['run']['name'])

 3B) Finally, add a "Terminate" step, and set it to "Failed" ("Cancelled" will also work, but I personally use "Cancelled" for other operations). You really want to do this, otherwise whenever a flow fails, it will show up as "Succeeded" because your second Scope executed successfully. This will obviously be really confusing when you start to investigate your flows.


Here is an overview of the full set-up:

abureaux_3-1753291322076.png


TIPS

  • The "Terminate" steps needs to be the FINAL step in the Scope. As soon as Power Automate runs that step, the flow will fully end, and anything after that step will be ignored. It is for this reason I actually use "Terminate" to help test flows in smaller chunks.
  • "Terminate" cannot be added to an Apply to Each loop.
  • You can add a bunch of steps to the second Scope. For example, in my more complex flows I have things like Conditions to delete items from SharePoint if there is an error--this helps avoid duplicate entries and unnecessary extra files. Example:abureaux_4-1753291642770.png
  • EDIT: One last tip. When adding multiple steps to your error handling scope, the "Send an email" should be the first real step. Looking at the image above, let's pretend something goes wrong with the "Update item - Process Fail - Job Started (No)" step. In that case, I wouldn't get the notification email, and so would assume everything was okay. Always send the email first, then try to clean up the mess!
ModernElectric
Frequent Contributor

@abureaux 

Thank you. I will add this to my design list and see what I can accomplish

0 Kudos
CalvinHarmin
Frequent Contributor

I have found ArcGIS connectors unreliable -- lots of authentication errors in the middle of hundreds of other successful runs. This is a separate issue from the 2-week re-authentication issue. 

I have changed my use of ArcGIS connector actions to using HTTP GET or POST actions using ArcGIS REST API instead. I'm not sure if this is possible for your workflows but I found it to be more reliable. This relies on getting an AGOL token first to use in the API call. The query output body has a "features" array that contains one or more features (if your query where clause had a match). 

CalvinHarmin_0-1753380113228.png

 

Get AGOL token child flow (I use the Solution feature of Power Automate so I can run child flows and have a migration pipeline from a development/test to production environment. Lemme know if you're curious about that). But this all that the child flow is doing -- another API call to get AGOL token:

CalvinHarmin_1-1753380277847.png

 

The actual query API call

CalvinHarmin_2-1753380305855.png

 

Compose attributes of the first result. Or you could do a For Each... action and do something with each feature if you expect to return more than 1. 

CalvinHarmin_3-1753380359771.png

 

 

0 Kudos
abureaux
MVP Frequent Contributor

From what I have seen, Esri has been greatly improving the built-in connectors over the last year. I feel like some of the more recent issues I've been seeing are a result of all the back-end work they are actively doing. Personally, I find them to now be better than the older REST API method, and am in the (very slow) process of replacing all my older flows with these newer connectors.

However, I have more recently noticed some "blips", where the get items steps doesn't work. But it doesn't last long and my flows all retry on fail so I haven't found it to be a significant hindrance to my workflow (which sees reports being generated nearly constantly for several workflows throughout the work day).

0 Kudos
CalvinHarmin
Frequent Contributor

Hm interesting, I've had the opposite experience -- I've only started using Power Automate ArcGIS connectors a few months ago, and I have had enough issues with the ArcGIS connectors that it was the weakest link in my whole solution and caused me anxiety and time spent tracking down fails and (re)processing things. It thankfully did force me to increase my error handling strategy. But it's been 2-3 weeks since my rewrite without the ArcGIS connectors for querying/updating features, and so far none have failed whereas I would have experienced something on the order of 10-20 fails in the same time period before. 

0 Kudos