Search techniques

  • Blue belt
  • Standard
  • Tip 168

Read the real error message with result()

Quiz question

What may result() point to in an expression?

Solution

  1. A) Any action anywhere in the whole flowWrong. If result() points to a simple action such as Compose, even saving fails.
  2. B) Only the trigger at the start of the flowWrong. The trigger contains no actions. result() needs a container with actions inside.
  3. C) A Scope, Apply to each or UntilCorrect. result() reads the actions inside such a container. If it points to a simple action, the flow cannot be saved.

What it is about

If a flow fails at night, the reason is in the run history. The people who need to know often cannot open it. The result() function gets you the details: result('Try') returns an array with all top-level actions of the scope Try, each with name, status, code and, for failures, an error object with the message. In an action that only runs on has failed, you filter the array with Filter array for status equal to Failed. You get the text with first(body('Filter_array'))?['error']?['message'] and send it by email. result() only works with a Scope, Apply to each or Until. If the error sits deeper, you apply result() to the inner level.

The expression from the tip

first(body('Filter_array'))?['error']?['message']

When to use it, when not

Use it

When business users, admins or an agent need to know why a run failed.

Better not

For actions outside the scope. result() only sees what is inside the container.

Most common mistake

Reading only the top level. Errors in a Condition or an inner Scope only appear in the result() of that level.

License

Standard Runs without a premium connector, so the license from Microsoft 365 is enough. Source on Microsoft Learn: Power Automate licensing FAQ. For your whole flow: License check.

Full tip on powerplatformtip.comPowerPlatformTip #168, with screenshots

Prefer to learn with guidance? The Power Automate live course of the Power Platform Academy takes you from the basics to error handling and scopes in four weeks.

Share

Short link: powerautomate.ninja/en/168

Source: PowerPlatformTip #168, Microsoft Learn: Employ robust error handling.