cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Care
Regular Visitor

Use FLOW to loop through table and send email

I have had a quick 1 hour introduction to PowerApps and I woul like to know if this is possible with FLOW.

I would like a flow that would fire every Every Monday morning and loop through my SQL vendor table and get all OPEN PO's 
I would then like to send 1 email to each vendor that has an open PO.
In My example
PlainVendor would get an email and that email would list 2 PO's on it. One for PO PL85R and one for PO DOG56
HappyVendor Would get an email with PO SAM78 on it
OldVendor Would not get an email because they have no open PO's    

 

Is this posible with PowerApps FLOW?
   Thank You So Much

VendorPOStatusVendorNameVendor Email
456ZX85BClosedHappyVendorHappyVendor@email.com
AB7PL85ROpenPlainVendorPlain@email.com
AB7DOG56OpenPlainVendorPlain@email.com
456SAM78OpenHappyVendorHappyVendor@email.com
967FROG1ClosedOldVendorOld@email.com
9 REPLIES 9
cwebb365
Super User
Super User

Yes. It’s late and I’m in bed so I can’t give much details but you can use sql connector in flow to query the data you need to get all the vendors emails that have a matching criteria and in that loop. You can put another query to get the items where the email is equal to the email on that run of the loop. And use those POs into an html table etc. and then send the email with that table. Then that loop goes for next email does same thing.

That’s the really high level version but yes it can be done ;). I have an example I use that I can post up tomorrow if you haven’t figured it out by then. Just shoot me a reply here so I have an email to follow up on if so.


Any and ALL help is welcome. 

As I said I am new to PowwerApps and greatly appreciate the help.

 

Thank You So Much

@cwebb365 wrote:
Yes. It’s late and I’m in bed so I can’t give much details but you can use sql connector in flow to query the data you need to get all the vendors emails that have a matching criteria and in that loop. You can put another query to get the items where the email is equal to the email on that run of the loop. And use those POs into an html table etc. and then send the email with that table. Then that loop goes for next email does same thing.

That’s the really high level version but yes it can be done ;). I have an example I use that I can post up tomorrow if you haven’t figured it out by then. Just shoot me a reply here so I have an email to follow up on if so.

 

Here is a snip of a flow I have that basically does the same thing. It uses a stored Proceedure to return a list of e-mail address of users/sites that are not compliant (no reading for the day), the loops through that list, sending each area manager a list of sites in their area missing readings. Hope this helps. 

 

poflow.JPG

v-alzhan-msft
Community Support
Community Support

Hi @Care ,

 

Have your problem been solved refer to @cwebb365 's solution?

If yes, please go ahead and mark the post as solved by clicking “Accept as Solution” so that this thread will be marked for other users to easily identify!

If no, please let me know and I would provide a proper workaround for you.

 

Best regards,

Alice       

 

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

I apologize I am Just getting back to this

I am stuck on the very first part of the Loop.

How do I get a "Results Set Table"  in there?

I am including my "GET" stored Procedure also. If you would please tell me if this is written correctly.

Thank You

USE [Sandbox]
GO
/****** Object:  StoredProcedure [dbo].[GetPurchaseOrderEmails]    Script Date: 9/23/2019 1:36:55 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[GetPurchaseOrderEmails] 
@VendorEmail varchar(50) OUTPUT 
AS
SET NOCOUNT ON;  
SELECT [VendorEmail]
  FROM [Sandbox].[dbo].[Destination]
  where PurchaseStatusDescription <> 'Closed'
  
 return

GO

I apologize I am Just getting back to this

I am stuck on the very first part of the Loop.

How do I get a "Results Set Table"  in there?


@cwebb365 wrote:

Here is a snip of a flow I have that basically does the same thing. It uses a stored Proceedure to return a list of e-mail address of users/sites that are not compliant (no reading for the day), the loops through that list, sending each area manager a list of sites in their area missing readings. Hope this helps. 

 

poflow.JPG


Thank You

You take the results from the stored proceedure run,  and put it in one of your steps, such as e-mail, or another SP and it will then loop based on that value. 

 

In my example, i use a SP to get e-mail addresses of people needing an alert. Then I have another execute SP where I use the e-mail results from the first SP, this then creates a loop, which I then use the results from the 2nd SP in the HTML table to build out the e-mail body info. 

Thank You so much for all of your help. Would you mind looking at my first SP.  Did I do it right?  It is getting all email addresses that have open po's?

Also  would you mind sharing your execute SP with me?  I could not find anything on  creating an Execute SP. 

USE [Sandbox]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[GetPurchaseOrderEmails] 
@VendorEmail varchar(50) OUTPUT 
AS
SET NOCOUNT ON;  
SELECT [VendorEmail]
  FROM [Sandbox].[dbo].[Destination]
  where PurchaseStatusDescription <> 'Closed'
  
 return


GO

My 2nd stored proc is just a stored proc that has an input, which I use that e-mail input in my select statement, so that each time that loop runs it passes the current e-mail address, and then I use that output for my table. So whatever columns you need for your e-mail you would have in your select and the @input would be e-mail address.

Once you have this other SP, you use the Output from the first SP in this case email, in the 2nd SP's input and flow will automatically add the loop in. Then use the 2nd SP's outputs in your HTML table / e-mail.

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 (4,468)