cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mwolf222
Level: Powered On

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
Highlighted
mwolf222
Level: Powered On

Re: how to stop a flow if condition fails

I got it to work.  Thanks!

10 REPLIES 10
Community Support Team
Community Support Team

Re: how to stop a flow if condition fails

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.
Super User
Super User

Re: how to stop a flow if condition fails

Hi!

There is also a "Terminate" action block

Hope this helps





If anybody solved your question, remember to mark its post as a solution!

Proud to be a Flownaut!





Highlighted
mwolf222
Level: Powered On

Re: how to stop a flow if condition fails

I got it to work.  Thanks!

Fresh1Doug
Level: Powered On

Re: how to stop a flow if condition fails

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). stop_a_Flow_example_2.pngSceen shot steps that will stop a Flow from running and prevent any further steps from executing.

 

Hamid
Level: Powered On

Re: how to stop a flow if condition fails

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

Filmbella
Level: Powered On

Re: how to stop a flow if condition fails

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

Super User
Super User

Re: how to stop a flow if condition fails

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.

 





If anybody solved your question, remember to mark its post as a solution!

Proud to be a Flownaut!





Filmbella
Level: Powered On

Re: how to stop a flow if condition fails

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

Super User
Super User

Re: how to stop a flow if condition fails

@Filmbella 

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





If anybody solved your question, remember to mark its post as a solution!

Proud to be a Flownaut!





Super User
Super User

Re: how to stop a flow if condition fails

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





If anybody solved your question, remember to mark its post as a solution!

Proud to be a Flownaut!





Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Users Online
Currently online: 385 members 5,036 guests
Please welcome our newest community members: