web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / how to stop a flow if ...
Power Automate
Unanswered

how to stop a flow if condition fails

(0) ShareShare
ReportReport
Posted on by

I have a condition in my Flow that puts an email attachment into a SharePoint folder if it has an x in the file name. 

The problem is, all attachments end up in the folder!  How to I stop a flow from proceeding (putting attachment in the folder) if it fails the condition?  I have tried "Stop Flow", but it doesn't work.  Thanks!

Categories:
I have the same question (0)
  • v-xida-msft Profile Picture
    on at

    Hi @mwolf222,

     

    Could you please share a screenshot of your flow’s configuration?
    I have made a test on my side and the flow works well. My flow’s configuration as below:12.JPG

    The flow works successfully as below:13.JPG

    Within "If/no" branch of Condition, we do nothing.

     

    Best regards,

    Kris

  • efialttes Profile Picture
    14,756 on at

    Hi!

    There is also a "Terminate" action block

    Hope this helps

  • Verified answer
    Community Power Platform Member Profile Picture
    on at

    I got it to work.  Thanks!

  • Fresh1Doug Profile Picture
    8 on at

    Adding detail to this solution to possibly help someone else--I came across this post when researching, but don't think that I understood or perhaps overlooked this "Terminate" comment.

     

    Using the "Terminate" control task will stop any subsequent Flow tasks from executing. Other methods, e.g. using a Condition check where the error path is set to "do nothing", may still trigger subsequent Flow steps. "Terminate" solves that problem.

     

    Below is a screenshot of steps that will stop a Flow when an error or timeout occurs. Simply adding the "Terminate" control (at bottom of screenshot) will stop the Flow. The additional steps sends an email notification and updates a boolean field that the record needs to be re-submitted at another time (triggered in a different Flow). Sceen shot steps that will stop a Flow from running and prevent any further steps from executing.Sceen shot steps that will stop a Flow from running and prevent any further steps from executing.

     

  • Hamid Profile Picture
    108 on at

    Hi 

    I have the same problem. after filtering out the emails based on their subject I put a condition to extract only excel files, but for some reason it extracts all the attachement with different formats. I tried to put the Terminate action if the condition is not met but it says Terminate Action dose not work for "For each attachemnet""Untitled2.png

  • Community Power Platform Member Profile Picture
    on at

    @Hamid - have you come up with a solution? I have the same problem.

  • efialttes Profile Picture
    14,756 on at

    Hi all

    "Terminate" action block can be used inside a condition, but not inside an Apply to Each. I usually add "Terminate" inside one of the branches of a condition, and keep on adding action blocks after the condition blocks.

     

  • Community Power Platform Member Profile Picture
    on at

    @efialttes - my condition is inside of Apply to Each and it won't fail if the conditions aren't met since "No" is an option. A "terminate" after that Apply to Each action is pointless. I need it to stop based on the condition inside the Apply to Each. Any ideas?

  • efialttes Profile Picture
    14,756 on at

    @Anonymous 

    Maybe a Do Until + an integer variable increasing its value by one.

    So, "Do Until" would depend on both there are still items in the array to be read, and we shall not terminate yet the evaluation.

    Using a "Do Until" is extremely tricky

    Hope this helps

  • efialttes Profile Picture
    14,756 on at

    Hi again

    In this post you will find a very very simple example of a Do Until.

    Now, imagine you initialize an integer variable 'i' as 0. You also initialize a boolean variable 'exit' as false. Then you enter the loop, inside it:

    -inspect the content of the i'th element of the array

    -decide if for some reason we shall stop evaluating array items, if so set 'exit' as true;

    -finally increment the integer

    So, 'until' expression shall stop looping either if 'i' is greater than the length of the array, or if 'exit' is set to true.

    If you finally opt to use 'Do until' please be careful with its limits.

    Hope this helps

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard