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

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power automate tips 768x460 v2.png

Restore a Deleted Flow

Did you know that you could restore a deleted flow? Check out this helpful article.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Users online (1,562)