Skip to main content

Notifications

Flow Failure Notifications

takolota1 Profile Picture Posted by takolota1 4,617

Get email alerts with direct links to the flow run any time your flow fails by adding this set of actions to the end of your flow.

Flowfailurpic.PNG


Either download the template attached to this post & copy the Scope in the template, or copy the Scope action's code, navigate to the My clipboard tab on a new action and press Cntrl + V to get this Scope as a new action option.

FlowFailCopyToClip.pngFlowFailCopyToClip2.png

 

 

Scope Code To Copy & Paste Into Your Flow

{"id":"fd3dfdb1-5fc7-4bb4-b830-978bffcb68b9","brandColor":"#8C3900","connectionReferences":{"shared_office365users":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_office365users/connections/4492902ae6154e088865fbb98252807a"}},"shared_office365":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_office365/connections/shared-office365-02d46624-0d5c-40fe-89f0-c5df-8c7ffde7"}}},"connectorDisplayName":"Control","icon":"data&colon;image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=","isTrigger":false,"operationName":"Scope_Failure_Notifications","operationDefinition":{"type":"Scope","actions":{"Compose_Flow_run_link":{"type":"Compose","inputs":"@concat('https://us.flow.microsoft.com/manage/environments/', workflow()?['tags']?['environmentName'], '/flows/', workflow()?['name'], '/runs/', workflow()?['run']['name'])","runAfter":{},"metadata":{"operationMetadataId":"304e2c8e-c6d8-4bd0-ac4d-57951dd57763"}},"Get_my_profile_(V2)":{"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_office365users","operationId":"MyProfile_V2","apiId":"/providers/Microsoft.PowerApps/apis/shared_office365users"},"parameters":{},"authentication":{"type":"Raw","value":"@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']"}},"runAfter":{"Compose_Flow_run_link":["Succeeded"]},"metadata":{"operationMetadataId":"16453b92-e67e-40aa-acf4-fbd90183a4f0"}},"Send_an_email_(V2)_Failure_notification":{"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_office365","operationId":"SendEmailV2","apiId":"/providers/Microsoft.PowerApps/apis/shared_office365"},"parameters":{"emailMessage/To":"@outputs('Get_my_profile_(V2)')?['body/mail']","emailMessage/Subject":"Your @{workflow()?['tags']?['flowDisplayName']} flow failed","emailMessage/Body":"<p>Check your flow.<br>\n<br>\n<a href=\"@{outputs('Compose_Flow_run_link')}\">Flow Run Link</a>&nbsp;</p>"},"authentication":{"type":"Raw","value":"@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']"}},"runAfter":{"Get_my_profile_(V2)":["Succeeded"]},"metadata":{"operationMetadataId":"bd4b39c2-3462-4a00-b21d-d8ac056f00d2"}},"Terminate_Mark_flow_run_failure":{"metadata":{"operationMetadataId":"c3050a38-c258-4145-b3fa-4d5e80d70b67"},"type":"Terminate","inputs":{"runStatus":"Failed"},"runAfter":{"Send_an_email_(V2)_Failure_notification":["Succeeded"]}}},"runAfter":{"Compose_(All_Your_Flow_Actions_Here)":["Failed","Skipped","TimedOut"]},"description":"Set this Scope's Configure run after settings to \"has failed\", \"is skipped\", and \"has timed out\".","metadata":{"operationMetadataId":"072e1b99-2b98-4cdc-bb50-f9ef10d9a137"}}}

 


Solution Zip Download Link: https://drive.google.com/file/d/1h2hpcuIAOwcXsuZmfGLjJmx29P9D6nX0/view?usp=sharing

Categories:

Desktop flows

Comments

  • JT-25070748-0 Profile Picture JT-25070748-0 5
    Posted at
    Flow Failure Notifications

    Thanks I'll try that!

     

  • takolota1 Profile Picture takolota1 4,617
    Posted at
    Flow Failure Notifications

    @Julie598 Use a condition action after the filter array set to if length(InsertFilterArrayBody) is equal to 0 then Send email

  • JT-25070748-0 Profile Picture JT-25070748-0 5
    Posted at
    Flow Failure Notifications

    @takolota Thank you - but technially its failed that important step of the flow - so I'd like to get notified - any ideas on how I do that? 

  • takolota1 Profile Picture takolota1 4,617
    Posted at
    Flow Failure Notifications

    @Julie598 

     

    That isn’t a failure. Your Filter array just didn’t return any records so the loop has nothing to iterate over.

  • JT-25070748-0 Profile Picture JT-25070748-0 5
    Posted at
    Flow Failure Notifications

    Hi, @takolota  I wonder if you can help please?  I've been using you scope failure notification for a while, thank you so much for this.  I have noticed that a lot of my flows have an apply to each action before the scope failure notication. If a step inside this action isn't triggered the scope action isn't picking this up and its not being triggered. Any ideas why? Here is a test I've set up:  (I've set this to fail on purpose to test it.)

     

    Julie598_0-1709563349392.png

     

    Julie598_1-1709563370732.png

    As you can see its not being triggered. 

     

    Julie598_2-1709563427445.png

     

    Thank you in advance.

  • takolota1 Profile Picture takolota1 4,617
    Posted at
    Flow Failure Notifications

    Alternate Power Apps Solution Import

     

    You can import the Power Apps Solution attached to this post. Once imported the flow template can be found in the Flows section inside the solution.

    SolutionPackageImport.png

  • takolota1 Profile Picture takolota1 4,617
    Posted at
    Flow Failure Notifications

    @Garth 

     

    Yes it should work with or without that scope.

  • Garth Profile Picture Garth 37
    Posted at
    Flow Failure Notifications

    Would this work, by putting everything in one scope?

    Garth_1-1685521810728.png

     

     

  • Garth Profile Picture Garth 37
    Posted at
    Flow Failure Notifications

    @takolota you comment on your Youtube video stating that this does not apply to Do Until and this poses a question for me. Before I begin here is a picture of what a failed run of my code looks like:

    Garth_0-1685519411899.png

    When it fails it is most likely going to be in the Do Until, but obviously want to capture failures outside of that as well.

    To this end could you advise where I put your code?

  • rseiler Profile Picture rseiler 116
    Posted at
    Flow Failure Notifications

    Thanks for this, but Microsoft really needs to improve their own notifications.

    Here's hoping that "Fix connection" type problems are seen less often with the connector used to send mail (of the sort used in this flow) than they are in other areas like OneDrive and SharePoint connectors. I don't know why any of those authentication problems occur at all absent a PW change, which we don't do, let alone why they seem to recur.