1 top tip - Get the result of your failed actions

Today, I bumped into the result function in Flow. We can now collect failed action details directly within the flow and report the failures in flows.

Failures in Flows

When things go wrong in your flow, there are some error message displayed in your Flow Run, however this means that a user needs to go to the flow run and find out where things went wrong.

Failed action in a flow

Quite often a user interested in the problem might not even have access to the flow run. Wouldn’t it be nice if you could send the error message from failed actions to the user or administrator so that failures in flows become more visible?

My regular followers will be aware of the Try-Catch pattern in Power Automate that I cannot stop talking about. The try catch, will already send the URL to the flow run, but now we can enhance this with the details of the failing action.

Collecting the result of a failed action

In the flow below the Compose action is failing. And the Compose 2  action is collecting the error message generated by the first Compose action

Get the error message in a compose action

Isn’t this what we have been waiting for for a long time?

The Result function

The result function is slightly harder to use than you might hope for. Although when you know how to use it it is easy to implement.

The result function in a compose action

According to the result function documentation, it returns the result of a scoped action.

If you refer to an action that isn’t a scoped  action then  you will see an error like the one below when you attempt to save the flow:

The template validation failed: ‘The workflow action ‘Compose_3’ at line ‘1 and column ‘1671’ references the action ‘Compose_2’ of type ‘Compose’: only the actions of type ‘System.Linq.Enumerable+WhereSelectArrayIterator`2[Microsoft.Azure.Flow.Templates.Schema.FlowTemplateOperationType,System.String]’ are allowed to be referenced by ‘result’ function. ‘.

So what is a scoped action? A Scoped action can be an Apply to each, Until or a Scope action.

This is going to open doors!

In my earlier example, all I had to do is set the Run after settings for my Compose 2 action to include to run on failure of the Scope and my result function can now give me the details of the action that failed.

Time to look at the output form the results function



    "name": "Compose",

    "startTime": "2020-03-06T09:42:59.1275689Z",

    "endTime": "2020-03-06T09:42:59.1275689Z",

    "trackingId": "06b9b7cc-f072-46d0-aa4f-b866ce7b2230",

    "clientTrackingId": "08586181191065299168785271735CU71",

    "clientKeywords": [



    "code": "BadRequest",

    "status": "Failed",

    "error": {

      "code": "InvalidTemplate",

      "message": "Unable to process template language expressions in action 'Compose' inputs at line '1' and column '2195': 'The template language expression 'split('tyrewftysdgjfhgjdsgjhdyufy','a')[3]' cannot be evaluated because array index '3' is outside bounds (0, 0) of array. Please see https://aka.ms/logicexpressions for usage details.'."



This is great, I’m getting  the results of my compose action inside the scope.
What happens when I have multiple actions inside my scope.

Multiple actions in a Scope

Time to add a second action inside my scope.

I added a Send me an email notification action and in the flow run I can see that this action worked while my Compose still fails.

Two actions inside a scope

The Compose 2 action now returns the result of all the actions, including the successful ones.

Result action when multiple actions in a scope



    "name": "Send_me_an_email_notification",

    "inputs": {

      "method": "post",

      "body": {

        "notificationSubject": "Test Email",

        "notificationBody": "Test email body"


      "path": "/sendEmailNotification",

      "host": {

        "api": {

          "runtimeUrl": "https://unitedstates-002.azure-apim.net/apim/flowpush"


        "connection": {

          "name": "/providers/Microsoft.PowerApps/apis/shared_flowpush/connections/shared-flowpush-f471b5e3-04fd-43ff-b943-b4b566dd1dd1"



      "authentication": {

        "value": "*sanitized*",

        "type": "Raw"



    "outputs": {

      "statusCode": 200,

      "headers": {

        "Pragma": "no-cache",

        "x-ms-request-id": "westus:eb24befa-3cba-4ffa-9479-d00dc320e015",

        "x-ms-correlation-request-id": "eb24befa-3cba-4ffa-9479-d00dc320e015",

        "x-ms-flow-mobile-ios-version": "1.3.0",

        "x-ms-flow-routing-request-id": "WESTUS:20200306T094725Z:eb24befa-3cba-4ffa-9479-d00dc320e015",

        "Strict-Transport-Security": "max-age=31536000; includeSubDomains",

        "X-Content-Type-Options": "nosniff",

        "Timing-Allow-Origin": "*",

        "x-ms-apihub-cached-response": "false",

        "Cache-Control": "no-cache",

        "Date": "Fri, 06 Mar 2020 09:47:25 GMT",

        "Content-Length": "0",

        "Expires": "-1"



    "startTime": "2020-03-06T09:47:23.9432031Z",

    "endTime": "2020-03-06T09:47:25.1776008Z",

    "trackingId": "1382cb46-803b-4be1-8697-dc448deaf3e7",

    "clientTrackingId": "08586181188417586183991966894CU91",

    "code": "OK",

    "status": "Succeeded"



    "name": "Compose",

    "startTime": "2020-03-06T09:47:25.2088528Z",

    "endTime": "2020-03-06T09:47:25.2088528Z",

    "trackingId": "0880bf08-aafa-42e2-b43b-ed89e3448e7d",

    "clientTrackingId": "08586181188417586183991966894CU91",

    "code": "BadRequest",

    "status": "Failed",

    "error": {

      "code": "InvalidTemplate",

      "message": "Unable to process template language expressions in action 'Compose' inputs at line '1' and column '2194': 'The template language expression 'split('tyrewftysdgjfhgjdsgjhdyufy','a')[3]' cannot be evaluated because array index '3' is outside bounds (0, 0) of array. Please see https://aka.ms/logicexpressions for usage details.'."



That is a lot of json just for the result of 2 actions!

Finding the failed actions

Yes indeed it is, you should however only need the results of the Failed actions. So you could for example run this output through a filter action so that you only get the failed actions returned. Now that we have the data that should be an easy step to take!

Some thoughts

The above idea of collecting the results of the actions should of course be included in the Try Catch pattern, however for the simplicity of this post I decided not to clutter this post.

I also found that the result function only returns 1 level of actions. If you use nested conditions or apply to each steps you might find that you have to run multiple result functions to get to the actual failure.
Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications Microsoft MVP working as a Principal Architect at HybrIT Services Ltd. You can contact me using contact@sharepains.com

4 thoughts on “Get the result of your failed actions in Power Automate”
  1. Result function only returns 1 level of actions, but the actual error is in further actions. How to get detail of error in further actions.

    1. This is indeed one of the limitations. Hence I would only use this where really needed as the error handling becomes a lot of overhead. For general error handling I would use the Try-Catch pattern.

  2. How do you handle nested actions? I am finding that, depending how deep the nested actions go, it has a failure at each level, but really only the last failure provides the true failure or error message. The only way I was able to get any of that was to union all my nested actions, which returns all the failures like the one that matters and the ones that dont. This method is not dynamic so you have to manually add each nested action to the union. I would like to find a way to get the last error message when there are nested actions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains by Microsoft MVP Pieter Veenstra

Subscribe now to keep reading and get access to the full archive.

Continue Reading