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

Power Automate - Send an email after the flow checks an Excel file for when a contract is expiring in 30 days

I've been going in circles trying to get my Power Automate flow to work and would like to know if anybody has a fix for my problem. What I'd like my flow to do:

 

In my excel sheet on SharePoint, there's a column that has "Contract End Date". Everyday in the morning at 9:00am to have an automatic recurrence flow to check if any of the values under "Contract End Date" expire in 30 days-using "addDays(utcNow(), 30, 'yyyy-MM-dd')", and for those contracts that do expire in 30 days to send an Email to a ME with a table that has the name of the contractor expiring and the date it does.

 

Obstacle: The current issue with my flow is that when it sends the Email, it'll send multiple counts of the email to each person if the "Send an Email" is under the if yes column. For example, if 5 people's contracts were to expire in 30 days, my current flow would send 5 of the same email with the table of the 5 people's contracts and names to the validator. When I pull the "Send an Email" outside of the "Apply to Each", it works in the sense that the flow sends me one email with exactly what I want if the condition is true, but if the condition is false, it'll still send an email with null values presumably since none of the data for the table has been read since it doesn't go down the is yes line.

I was wondering if anybody had a workaround.

 

Schwalbe_0-1617820082145.png

Schwalbe_1-1617820120179.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
NorthernChuck
Helper III
Helper III

Well you are inside a loop that is evaluating row by row (or record by record depending on your nomenclature) 
So then if you evaluate that your adddays function is equal to that Contract... function you then do whatever to create your HTML table. Because it is row by row you have no way of forcing it to only email the recipient once; it'll email each recipient identified in each evaluated row that matches. 

You want ALL ROWS that have a date/time matching your algorithm for an email.
Then you want to grab each recipient and add their corresponding "Contract ID and Expiry Date" to an email body and send. <--- is this an accurate description of your intent? If so, then you want to hit "Show Advance Options" under "List Rows Present In Table" and do an OData filter. 
I might create an additional column called "contact_now" and then update it to a YES or NO depending on an adddays thing. Once that column is updated, then do an easy OData filter contact_now eq YES

View solution in original post

1 REPLY 1
NorthernChuck
Helper III
Helper III

Well you are inside a loop that is evaluating row by row (or record by record depending on your nomenclature) 
So then if you evaluate that your adddays function is equal to that Contract... function you then do whatever to create your HTML table. Because it is row by row you have no way of forcing it to only email the recipient once; it'll email each recipient identified in each evaluated row that matches. 

You want ALL ROWS that have a date/time matching your algorithm for an email.
Then you want to grab each recipient and add their corresponding "Contract ID and Expiry Date" to an email body and send. <--- is this an accurate description of your intent? If so, then you want to hit "Show Advance Options" under "List Rows Present In Table" and do an OData filter. 
I might create an additional column called "contact_now" and then update it to a YES or NO depending on an adddays thing. Once that column is updated, then do an easy OData filter contact_now eq YES

View solution in original post

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (1,538)