cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

how to stop a flow if condition fails

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

I got it to work.  Thanks!

View solution in original post

10 REPLIES 10
v-xida-msft
Community Support
Community Support

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

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi!

There is also a "Terminate" action block

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Anonymous
Not applicable

I got it to work.  Thanks!

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.

 

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

Anonymous
Not applicable

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

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.

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Anonymous
Not applicable

@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?

@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



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



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



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (1,973)