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 tell "if" condi...
Power Automate
Unanswered

How to tell "if" condition to move on after "yes" response

(0) ShareShare
ReportReport
Posted on by 34

Hello, 

 

I need some help with a flow I am working on. What I am doing is I am capturing responses from a form and then creating a sharepoint list and Sales Force entries with the information from the form. In order to avoid duplicate accounts for companies though I have flows set up to check against the sales force "Accounts" information. What I need to do is configure the flow to move on and stop checking the rest of the records after getting a yes response. 

 

flow.png

 

So here it is scanning through all 400+ records from our sales force account to find a match for the company name from the form response. Once it gets a "yes" that there is a match then I want it to stop checking the rest of the records and move on to the next step in the flow. If it scans all of the records and gets a no from each of them then it should follow the no path. 

 

Please help 

Categories:
I have the same question (0)
  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @rickmontezuma 

     

    So you mean that you want to stop the flow when the first Yes is encontered? If so, just below the create record action of the yes tab, add an action and search for terminate. Select the terminate action and set the status on that. asc.png

     

    Hope this Helps!

     

    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!

     

  • Ed Gonzales Profile Picture
    4,531 Most Valuable Professional on at

    update:  @yashag2255 beat me to it 🙂   But validating to know I was on the right path.

     

    @rickmontezuma 

    Hi there.

    I'm not certain this will work...just seems like it should.  Try putting a Terminate action after the update:20190627a.PNG

     

    You can use a different status, I just chose "Succeeded".  Keep us posted.

    -Ed-

     

     

    If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

  • rickmontezuma Profile Picture
    34 on at

    I get an error message when I try to add that function that says "The operation 'terminate' cannot be used inside a for each."

  • ScottShearer Profile Picture
    25,270 Most Valuable Professional on at

    @rickmontezuma 

    I don't have a Sales Force account - can you tell me if the action that you are using supports OData filters?

     

  • rickmontezuma Profile Picture
    34 on at

    @ScottShearer there are a couple of different steps going on here but the "Get Recrods" salesforce action does support OData

  • Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    Create a boolean variable above the loop and set it to True.  Then inside you Apply to each set the variable to False if you find the account you want.  Then put your main condition inside a condition that checks that variable.  If the variable is still true it will check for the company and process it.  If the company has already been found it will skip the whole thing.  You'll still iterate through everything, but you won't do any of the actions after you set the variable to False.

  • ScottShearer Profile Picture
    25,270 Most Valuable Professional on at

    Then why not use an OData filter and refer to item zero in the collection that is returned - that is the first record.  Also , you can use the length expression to check the number of records returned - if it is zero, then you know that no records were returned.   This eliminates the need to loop through the items.  If I had access to SalesForce I could explain better with screen shots.....

     

  • rickmontezuma Profile Picture
    34 on at

    Could you please elaborate and provide a screen shot of what you are referring to @Pstork1 

  • rickmontezuma Profile Picture
    34 on at

    I tried adding the company name response from the form to the "Get Records" query to try and only pull that record but it failed when I did that @ScottShearer 

  • Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    My solution uses two conditions.  The outer one checks to see if you have set StopLoop to True.  If not it does the condition you have in your Flow.  If that condition finds the Company that matches the Account then it does its work and sets StopLoop equal to True. Then on the next loop the first condition directs the program to the empty no side of the outer condition.  It continues to do that through the rest of the Loop since there is no way to exit an Apply to Each loop early.  Here's a screen shot that shows the Loop and the outer condition check.

    screenshot.png

     

    And this screenshot expands the inner condition that contains your original logic plus the action to set the StopLoop variable 

    Screenshot2.png

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 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard