cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
MPayne-94
Level: Powered On

Alternative to "For Each" conditions

Is there an anternative for Conditions that doesnt result in a "For Each"?

 

I am trying to set up a reccurance that will trigger a single email based on the value of a column in a SharePoint List. The issue I am running into is when I set up my condition to see if the list has the value associated with the email it will create a For Each and will then trigger an email to send for every list item that has the column value that I am searching for.

 

Are there any work arounds on this?

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Alternative to "For Each" conditions

@MPayne-94 

I have created an example that should help you out.

I use a filter query in my get items action so that only the items that meet my criteria are returned (in my case where MyStatus is equal to C).

I have a condition so that I only go forward if there are items returned by Get Items - don't want to send an empty email.  The expression that I use in the condition can be seen in the action comments.

Than I create an HTML table and embed the table in the email.  Note that I am using the new email action (V2) - if you use the older Send email action, you'll need to go to advanced options ans set "Is HTML" to yes.

 

SingleEmail1.jpgSingleEmail2.jpg

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

8 REPLIES 8
Dual Super User
Dual Super User

Re: Alternative to "For Each" conditions

Hi @MPayne-94 

 

alternative to for each would be to use expressions

 

If you can post a sscreenshot of your current Flow and highlight the for loop you are trying to avoid to only send the single email, it would help

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

MPayne-94
Level: Powered On

Re: Alternative to "For Each" conditions

For sure. Screens shots are below of what I have built now:

 

The Apply to each has 5 conditions in it based on status value( Created & Waiting, Accounting Complete, Manager Approved, Comm Ops Approved, Purchasing Complete, Completed New Item Set Up) that are supposed to trigger the singualr email. 

Annotation 2019-08-08 095356.pngAnnotation 2019-08-08 095451.png

Dual Super User
Dual Super User

Re: Alternative to "For Each" conditions

Hi @MPayne-94 

 

 

Get Items action - do you have a query to only fetch the single record you need?

Looks like you are getting all items

 

 

Super User
Super User

Re: Alternative to "For Each" conditions

@MPayne-94 

I have created an example that should help you out.

I use a filter query in my get items action so that only the items that meet my criteria are returned (in my case where MyStatus is equal to C).

I have a condition so that I only go forward if there are items returned by Get Items - don't want to send an empty email.  The expression that I use in the condition can be seen in the action comments.

Than I create an HTML table and embed the table in the email.  Note that I am using the new email action (V2) - if you use the older Send email action, you'll need to go to advanced options ans set "Is HTML" to yes.

 

SingleEmail1.jpgSingleEmail2.jpg

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

MPayne-94
Level: Powered On

Re: Alternative to "For Each" conditions

No I do not. That is where I am running into the issue. Cant seem to create anything with my knowledge base that doesnt include the Apply to Each

Super User
Super User

Re: Alternative to "For Each" conditions

@MPayne-94 

If you take the example that I have provided and use it as your template, it should work for you.  The Flow that I provided runs without error.  Please give it a try and post here (with screen shots) if you experience any issues. 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
MPayne-94
Level: Powered On

Re: Alternative to "For Each" conditions

For the other status values that i am looking for those would just be additional conditions branching off the initial condition for "C" in your case

Super User
Super User

Re: Alternative to "For Each" conditions

@MPayne-94 

You can extend the filter query with additional parameters.  Here is a link to a blog post that explains how.

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

Helpful resources

Announcements
firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

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 (5,226)