Skip to main content
Power Automate
    • Connectors
    • Templates
    • Take a guided tour
    • Digital process automation
    • Robotic process automation
    • Business process automation
    • Process Mining
    • AI Builder
  • Pricing
  • Partners
    • Blog
    • Documentation
    • Roadmap
    • Self-paced learning
    • Webinar
    • Business process and workflow automation topics
    • Overview
    • Issues
    • Give feedback
    • Overview
    • Forums
    • Galleries
    • Submit ideas
    • User groups
    • Register
    • ·
    • Sign in
    • ·
    • Help
    Go To
    • Microsoft Power Automate Community
    • Welcome to the Community!
    • News & Announcements
    • Get Help with Power Automate
    • General Power Automate Discussion
    • Using Connectors
    • Building Flows
    • Using Flows
    • Power Automate Desktop
    • Process Mining
    • AI Builder
    • Power Automate Mobile App
    • Translation Quality Feedback
    • Connector Development
    • Power Platform Integration - Better Together!
    • Power Platform Integrations
    • Power Platform and Dynamics 365 Integrations
    • Galleries
    • Community Connections & How-To Videos
    • Webinars and Video Gallery
    • Power Automate Cookbook
    • Events
    • 2021 MSBizAppsSummit Gallery
    • 2020 MSBizAppsSummit Gallery
    • 2019 MSBizAppsSummit Gallery
    • Community Engagement
    • Community AMA
    • Community Blog
    • Power Automate Community Blog
    • Community Support
    • Community Accounts & Registration
    • Using the Community
    • Community Feedback
    cancel
    Turn on suggestions
    Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
    Showing results for 
    Search instead for 
    Did you mean: 
    • Microsoft Power Automate Community
    • Galleries
    • Power Automate Cookbook
    • Power Automate Errors Logging

    Power Automate Errors Logging

    08-23-2022 02:23 AM - last edited 08-23-2022 02:31 AM

    Super User MarconettiMarco
    Super User
    6829 Views
    LinkedIn LinkedIn Facebook Facebook Twitter Twitter
    MarconettiMarco
    Super User MarconettiMarco
    Super User
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    Power Automate Errors Logging

    ‎08-23-2022 02:23 AM

    When creating workflows, we find it very helpful to use error logging to track Power Automate results so they can be supported by a broader audience.


    By default, Power Automate will exit the flow at the point of failure. Periodic email notifications will be sent to the owner(s) of the Power Automate. Here you can see a 28-day run history and any run failures.

    Note: if a Power Automate fails continuously for 14 days, it will automatically be turned off 

     

    So, from my point of view, it’s necessary to log somewhere the errors in order to:

    • Notify periodically (once per day/week) the flow owner or a Team of users, so that they can take action;
    • Enrich the DB that should allow to build Insights.

       

     

    There is better way for handle errors and log all Power Automate flow instances to a single place.

    In my case, I’m storing the PA errors in a Dataverse Table, but it’s also possible to use for instance a SharePoint List.

    Here the steps to be followed:

    • Create a Dataverse table named in my case “Power Automate Errors Logging” from Power Apps
    • Create the following columns and add the to the main Form:
      • “Action”: single line of text;
      • “startTime”: Date and time;
      • “endTime”: Date and time;
      • “Run url”: Url;
      • “status”: single line of text;
      • “statusCode”: single line of text;
      • “Error message”: single line of text;
    • From the already generated Table, create a Model-Driven Apimage-20.png

     

    • Then let’s move to Power Automate: for each PA flow, it’s necessary to add:
      • a first Scope-Try control in which put all the Actions the flow must perform
      • a second Scope-Catch control in which put all the Action the flow must perform if at least one of the Actions included in the Scope-Try control has failed or timed out.

    image-22.png

    image-150.png

    So, click on the “Scope-Catch” 3 dots and select “Configure run after”

    Capture.PNG

     

    Then, select the options “has failed” and “has timed out”, finally click on “Done”.

    image-152.png

     

    Within the “Scope-Catch” control, please add in sequence the following Actions:

    • to get the run ID, add a “Compose” action, name it “Compose-WF ID” and put the following expression: workflow()

    image-26.png

    • to get the run url, add a “Compose” action, name it “Compose-Run URL” and put the following expression (please change “emea” with your correspondent region): concat('https://emea.flow.microsoft.com/manage/environments/', outputs('Compose-WF_ID')['tags']['environmentName'], '/flows/', outputs('Compose-WF_ID')['name'], '/runs/', outputs('Compose-WF_ID')['run']['name'])

    image-27.png

    • to get the “Scope-Try” result, add a “Compose” action, name it “Compose-Scope Result” and put the following expression: result('Scope-Try')

    image-28.png

    • to get the result properties, add a “Parse JSON” action, name it “Parse JSON-Scope Result:
      • put the “Compose-Scope Result” outputs in the “Content” field
      • put the Schema by using the function “Generate from sample”. In order to get the full body, please run the flow and get the “Compose-Scope Result” output, copy and paste it in the “Generate from sample” function

    image-29.png

    • to get only the failed actions, add a “Filter array” action:
      • From: Body got from the “Parse JSON” action
      • condition: string(item()?['outputs']?['statusCode']) does not start with string('20')

    image-153.png

    • to generate a column in the Dataverse table “Power Automate Errors Logging”, add an “Apply to each” control, selecting the Body from the “Filter array” action to be added in the “Select an output from previous steps” field. Into the Apply to each loop add a Dataverse “Add a new row” action, name it “Add a new row-PA Error Logging and put the following values:
      • Name: put the following expression: workflow()?['tags']?['flowDisplayName']
      • Action: put the “name” got from the Filter array;
      • startTime: put the “startTime” got from the Filter array;
      • endTime: put the “endTime” got from the Filter array;
      • Error message: put the following expression: items('Apply_to_each-Add_PA_Error_Logging_row')['outputs']['body']['error']['message']
      • Run url: put the outputs from the “Compose-Run URL” action;
      • status: put the “status” got from the Filter array;
      • statusCode: putt the “statusCode” got from the Filter array.

    image-154.png

     

    • finally, within the “Apply to each” control” add a “Terminate” action with status “Failed”.

    image-32.png

    Here the entire “Scope-Catch” control:

    image-155.png

     

    Here the output:

    image-36.png

     

     

    image-37.png

     

    Hope it helped!

    Thanks for your feedback.

     

    @DamoBird365 @Paulie78 what do you think about this topic?

     

    My blog site about Power Automate: https://powerautomatejoy.com/

    BR,

    Marco

    PowerAutomateErrorsLogging_20220823085337.zip
    Labels:
    • Labels:
    • Automated flows
    Message 1 of 3
    6,829 Views
    6 Kudos
    Reply
    • All forum topics
    • Previous Topic
    • Next Topic
    takolota
    Super User takolota
    Super User
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎08-24-2022 02:16 PM

    What are the intended use cases?

     

    I’ve created a pretty simple template for immediately alerting flow owners of failures for less enterprise-level scenarios: https://powerusers.microsoft.com/t5/Power-Automate-Cookbook/Flow-Failure-Notifications/td-p/1494079

    So in a lot of cases I think it should be the flow owner’s responsibility to troubleshoot errors & ideally one creates their flows in a way where it won’t consistently error to the point where they need a long log of all the errors.

     

    Is this more for monitoring teams of flow builders & keeping failure records for historical analysis, identifying training gaps, & common issues?

    Or could it also be used for other things?

     

    I wonder if Microsoft somehow tracks this kind of stuff across most users.

    It would be interesting if we could see a consistent display of the most common errors across most users on the platform. Then people could better target their content & training aids.

    Message 2 of 3
    6,775 Views
    0 Kudos
    Reply
    MarconettiMarco
    Super User MarconettiMarco
    Super User
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎08-24-2022 10:53 PM

    Hello @takolota ,

    many thanks for your feedback!!!

     

    For sure, in regards of "critical" flows, we can manage the instant Teams/Email notifications, just to be sure that the user is notified and takes actions as soon as possible.

    I'd prefer to store the flow failures somewhere (i.e. Dataverse or SharePoint), in order to:

    • Create a permanent history of flow runs. I can monitor trends and see how often a flow fails. The list also gives me a direct link to each flow history run which can make it easier to track down a particular failure;
    • Keep track (in Dataverse or SharePoint) of the history of actions taken in order to solve the issue. So, in other word, it's possible to assign the row in Active status, and push the user to close the "ticket";
    • Enrich the DB that should allow us to build Logics and Insights;
    • Don't spam users regarding "non critical" flows, in another article I'm going describing how to send periodic email notifications: https://powerautomatejoy.com/2022/07/26/periodic-errors-logging-notification/

     

    I'd love if Microsoft in the next future will release something like a much more consistent report and not limiting, like today, the history to 28 days!

     

    I may not have all the answers, but I'm curious and passionate enough to keep looking for answers and to keep sharing them.


    My blog site about Power Automate: https://powerautomatejoy.com/

    BR,

    Marco

    Message 3 of 3
    6,768 Views
    2 Kudos
    Reply

    Power Platform

    • Overview
    • Power BI
    • Power Apps
    • Power Pages
    • Power Automate
    • Power Virtual Agents

    • Sign up free
    • Sign in

    Browse

    • Templates
    • Connectors
    • Partners

    Downloads

    • Mobile
    • Gateway

    Learn

    • Documentation
    • Learn
    • Support
    • Community
    • Give feedback
    • Blog
    • Pricing

    • © 2023 Microsoft
    • Contact us
    • Trademarks
    • Privacy & cookies
    • Manage cookies
    • Terms of use
    • Terms & conditions
    Consumer Privacy Act (CCPA) Opt-Out Icon Your Privacy Choices