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

Three conditions to run

I have three conditions that I am needing to run and if criteria is met then send email but would like to have the first one run and if it successfully sends an email then I would like the flow to stop and not run the other conditions. Is this possible? Can someone explain how to do this?08-20-2019 11-12-24 AM.jpg

4 REPLIES 4
Super User
Super User

Re: Three conditions to run

Hi @Tbruns 

 

If I understood correctly you need to split your IF conditions with each flow actions. If not send an example of your requirement.

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!



Sarah_Bull
Level: Powered On

Re: Three conditions to run

This might be too basic a suggestion, but could you add a 'condition' or 'case' action inside your 'Apply to each' operations? You could have one branch that contains no further actions.

 

You could also use a 'Do Until' loop. For example:

  1. Initialize 2 variables, 'arrayIndex' (integer - 0) and 'stopFlow' (boolean - false)
  2. Set up a 'Do Until' loop where the arrayIndex increments each time and is used to get each item in sequence. The loop stops either when arrayIndex is maximum, or stopFlow is true. When an item matches the condition, stopFlow is set to true.

Then, if stopFlow is still false after the first 'Do Until' loop completes, you can run your other operations afterwards.

 

There is a 'Terminate' action in Flow that might also be useful to you, but you can't use that inside the loop.

 

Hope this helps!

Tbruns
Level: Powered On

Re: Three conditions to run

Yes so I would like Condition "Pending" to run and if the criteria is met and it sends an email then I do not want the other two to run. If the criteria is not met then I want the next condition "Meet or Does Not Meet Criteria" to run. If the criteria is met and sends an email then I do not want the third one to run. If it doesn't send an email then I want the third to run.

I am still learning so examples would be appreciated as I don't understand some of the "terms" of Flow.

Sarah_Bull
Level: Powered On

Re: Three conditions to run

Hi @Tbruns, it sounds like you want the conditions to run like this:

  1. Loop through all the items - if Condition "Pending" is met, do not run the other two conditions
  2. Loop through all the items - if Condition "Meet or Does Not Meet Criteria" is met, do not run the other condition
  3. Loop through all the items and run the third condition

My big question to you is, 'Do you want to stop running your loop the first time one item in your list meets any of your three conditions? Or, do you want to run your first condition on all list items, your second condition on all list items (only if the first condition failed), and then your second condition on all list items (only if the other two conditions failed).

 

If it's the case that you want to stop running your loop the first time one item in your list meets any of your three conditions, here's my understanding of your workflow:

  1. Initialise the variable 'stopFlow'. This is the value that will tell you when a condition is met and you don't need to run any more conditions.
  2. Loop through all the items in the list.
    • Check whether the 'stopFlow' variable is true. If it is, you don't need to do anything. If 'stopFlow' is false, continue.
    • Check your 'Pending' condition for that item. If the condition is true, send your email and set 'stopFlow' to true (so no further actions will be carried out).
    • Check your 'Meet or Does Not Meet' condition for that item. If the condition is true, send your email and set stopFlow to true (so no further actions will be carried out).
    • Check your third condition for that item. If the condition is true, send your email and set stopFlow to true (so no further actions will be carried out).
    • If no conditions were valid, continue to the next item in the list.

I've attached an example Flow image. It starts off like yours, triggered by when an item is added to the list. Then it uses 'Initialize Variable' to create the stopFlow variable (set to false initially). Then comes the loop. Apply to each list item, first check that the conditions have not yet been satisfied. Then, I get the item.

 

Below, I've used the 'Switcher' action to process the item. This lets you set multiple alternatives provided they're all on the same field (e.g. if status is 'Pending', carry out the actions in case1; if status is 'In Progress', carry out the actions in case2, and so on). If one of the 'Switch' options satisfies the conditions, then I send an email and update 'stopFlow' to true to show I don't need to run any of the other conditions. If you can't use a Switcher for your circumstances, you can use multiple 'Conditions' instead.

flow condition switching.png

 

Hope this gives you some ideas.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

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 Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,716)