Skip to main content

Notifications

Community site session details

Community site session details

Session Id : Fb3q3u0Pp9kSExeddv1RC9
Power Automate - General Discussion
Suggested answer

Failed action has 'run after failure' but flow still fails and gets turned off

Like (1) ShareShare
ReportReport
Posted on 14 Aug 2024 09:02:34 by 2
Hi,

I have a flow that checks if a future, current or passed employee has an O365 account. Normally accounts are blocked when an employee leaves the company and deleted after 90 days. We want a sharepoint list that doublechecks.
  1. Once a day the flow is triggered
  2. We 'get items' from a sharepoint list of all employees
  3. We use ‘get user profile (v2)’  in a loop to get every employees O365 profile
  4. If they have a profile -> the user has an account, we check if it’s enabled or disabled and write this to our sharepoint list
    If they don’t have a profile -> ‘get user profile (V2) fails. We’ve set a ‘run after fail’ and write ‘no account’ to our sharepoint list.
No issues there. It works perfectly.

Except, when ‘get user profile(V2)’ fails power automate considers the entire flow a failure, even though a run after fail is set. After a while it turns the flow off automatically because it keeps failing.

I can’t use a terminate action, because my loop still needs to cycle through all the other employees.
 
Any ideas?
 
Thanks
Categories:
  • abc 123 Profile Picture
    784 Super User 2025 Season 1 on 14 Aug 2024 at 11:59:54
    Failed action has 'run after failure' but flow still fails and gets turned off
    Due to the fact that Microsoft takes it upon themselves to turn off a Flow that "Fails", I now try to terminate with a "Cancel", instead of "Fail", whenever possible. For example, logical errors get a Cancel, but calls to a Child Flow that choke still get a Fail. 
     
    To do this, initialize a variable, called strFlowStatus, to "Success".
    Whenever a trapped error happens, set the variable to "Cancel" when in that branch.
    If the Flow truly fails, meaning a non-bizlogic fail, then set the variable to "Fail".
     
    At the end of the Flow, add a Switch Action, and Handle each status, "Success", "Cancel", and "Fail", separately.
     
    For extra credit, when there is a true Fail, I send an email to myself.  
  • Suggested answer
    Pstork1 Profile Picture
    66,004 Most Valuable Professional on 14 Aug 2024 at 11:49:12
    Failed action has 'run after failure' but flow still fails and gets turned off
    It sounds like you are using the Run After inside the loop.  That will work, but it doesn't prevent the error from rolling up to the containing loop.  So make sure you have at least one action after the loop finishes set to run when the loop succeeds or fails.  Here's a screenshot of an example.  You can see that the Get user profile failed and the run after action runs. But the flow itself failed until I added the final Compose set to run if the loop succeeded or failed.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,668 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard