Read the real error message with result()
Quiz question
What may result() point to in an expression?
Solution
- A) Any action anywhere in the whole flowWrong. If result() points to a simple action such as Compose, even saving fails.
- B) Only the trigger at the start of the flowWrong. The trigger contains no actions. result() needs a container with actions inside.
- 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, with fields such as name, status and code, plus an error object with a message depending on the failure. 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. For nested failures, inspect the inner container. Only read a message if the filtered array is not empty.
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. For nested actions, inspect the inner container and check whether error.message exists.
License
Standard This technique uses standard connectors. Microsoft 365 usage rights cover standard connectors. Check the rights for your whole flow. Source on Microsoft Learn: Power Automate licensing FAQ. For your whole flow: License check.
Share
Short link: powerautomate.ninja/en/168
Source: PowerPlatformTip #168, Microsoft Learn: Employ robust error handling.
Prefer to continue with guidance? The Power Automate live course (in German) at the Power Platform Academy runs over four weeks. The next dates are not set yet, you can join the waiting list on the course page.