Collect flow runs of your failed child flows

When you use child flows, you might need to collect the flow runs of your failed child flows to identify any issues. In this post some error handling tips.

Introduction into error handling

We all know (or should know) how to do basic error handling in flows. And then a while back I also wrote about error handling in child flows.

And I’ve explained that the following expression can give you the url to your flow run:

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

Now when you use child flows you could consider getting each failed child flow run to send you an email in the Catch scope of the flow, but before you know it you will get 100s of emails when things go wrong in the child flow.

File synchronization use case

Today I looked at a flow that would synchronize two document libraries. I’m not going to look at the details of that flow. But in short, I’ve got two flows.

The parent flow looks like this:

Collect flow runs of your failed child flows Microsoft Office 365 image

So I’m reading some records out of Dataverse and then for each of the records I’m starting a child flow

Now each of those child flows could fail or be successful.

Imagine if I kick off 1000 child flows and 50 of them fail. It would be quite a pain to identify those.

In my posts about the Try Catch template you will have noticed the same expression as I mentioned above in this post. So I would like to collect all the urls of the flow runs. So that I can email them in a single email at the end of my parent flow run.

Configure the child flow

now we need to add a Respond to a PowerApp or flow action to both the Try and the Catch scope. It is important that both these response to a PowerApp or flow actions have the same fields specified. Ifthey are not the same you will get an error message on saving the flow.

Collect flow runs of your failed child flows Microsoft Office 365 image 1

In the above example you could also add something that helps you identify the flow run. Something like a file name or a title of a record can be very helpful. but for the simplicity of this post I will ignore that bit.

The flow runs of your failed child flows

Now the final part of this solution. Using Pieter’s method I’m going to collect all the results from all the flow runs in a Compose action that has been renamed to Results.

Collect flow runs of your failed child flows Microsoft Office 365 flow runs of your failed child flows

So now we have an array of results that we can use within the email that is sent out when the parent flow fails.

However as the child flow doesn’t fail (we handled the failure, hence the flow is successful. We can now look at this array, filter the failed records out using the filter action.

So in the Filter actions show below we can look at the Result property ( expression used : item().Result )

Then in the condition we will count the number of failed record found by the filter action. and finally an email is sent out with the link of the parent flow and a full record of all the flow runs of your failed child flows.

flow runs of your failed child flows

Continue Reading Pieter Veenstra’s Article on their blog

https://sharepains.com/2022/03/07/flow-runs-of-your-failed-child-flows/

Blog Syndicated with Pieter Veenstra’s Permission

Author: Pieter Veenstra

Share This Post On
Share via
Copy link
Powered by Social Snap