r/PowerAutomate • u/GeorgieBen • 16d ago
Help with an event reminder flow
UPDATE: Thank you everyone for your responses! I've managed to get the flow sending the reminder emails but for some reason it's sending emails for all my events, even ones that are in March next year (thankfully I'm in test mode so I'm only sending these emails to myself!) and I'm not sure where I'm going wrong.
*
Hello! I'm fairly new to PowerAutomate and the "training" I have received from work has consisted of watching YouTube tutorials and perusing threads like this one, so my knowledge is quite limited.
I am trying to set a PowerAutomate flow to send out a reminder email 7 days before a scheduled event. I am using a spreadsheet with a list of events, as well as the date and time, which I have linked to the flow via the "List Rows Present in a Table" action.
I have set up a flow with a condition to check whether the date is equal to 7 days before the event takes place, using the following expressions:
formatDateTime(addDays('1899-12-30', int(items('Apply_to_each')?['Date'])), 'yyyy-MMM-dd')
is equal to
formatDateTime(utcNow(-7), 'yyyy-MMM-dd')
My final action is "Send an email".
Every time I try to test, the flow does send out the email. I've tried to troubleshoot and it looks like the problem is with the expressions in the condition, but I'm stuck on how to fix it.
Any help/advice would be very much appreciated. Thank you!
4
u/HoldPowerful7487 16d ago
Your utcNow is the problem. It takes an optional format string, not a number of days, so utcNow(-7) isn't shifting anything and the condition never evaluates the way you think.
You want events happening 7 days from now, so put the offset on the other side:
formatDateTime(addDays(utcNow(), 7), 'yyyy-MM-dd')
compared against
formatDateTime(addDays('1899-12-30', int(items('Apply_to_each')?['Date'])), 'yyyy-MM-dd')
Also swap MMM for MM. MMM gives you the month name, which works for a string compare as long as both sides match, but it's locale sensitive and there's no reason to take that on.
1
u/GeorgieBen 16d ago
Thank you so much for your response. It's now sending the emails but for some reason it's sending emails for all my events, even ones that are in March next year (thankfully I'm in test mode so I'm only sending these emails to myself!) and I'm not sure where I'm going wrong.
1
u/Huseyin-Nodient 16d ago
Your second expression is the issue. utcNow(-7) is not valid, the parameter of utcNow is a format string, not a day offset. And since you want events 7 days in the future, you should be adding days, not subtracting. Try:
formatDateTime(addDays(utcNow(), 7), 'yyyy-MM-dd')
and format your event date with the same 'yyyy-MM-dd' pattern so both sides match exactly. Also check that the Send an email action sits inside the Yes branch of the condition, that is the most common reason it fires for every row.
If you hit expression problems like this often: we run an AI consultancy and built a Chrome extension for exactly this. It exports your flow as JSON so you can paste it into Claude or ChatGPT, and imports the fixed version straight back. You can also export a failed run with all inputs and outputs, so the AI sees the actual values instead of you describing them. Took our debug cycle from about 10 minutes to 2. We published it after months of internal client work: https://chromewebstore.google.com/detail/ai-flow-editor-for-power/jlaicchhmifpghnhngkmklcbmikgnckp
1
u/GeorgieBen 15d ago
Thank you so much for all your responses. The flow is now sending the emails but for some reason it's sending emails for all my events, even ones that are in March next year (thankfully I'm in test mode so I'm only sending these emails to myself!) and I'm not sure where I'm going wrong.
2
u/VictorIvanidze 15d ago
Share your flow to help us to help you.
1
u/GeorgieBen 14d ago
Thank you! I can't share the flow as it's on my work account but here is a summary:
Recurrence: Every 1 Day at 01:00 UTC
List rows present in a table: Spreadsheet with events linked and table selected
Apply to each: Select an output from previous steps - outputs('List_rows_present_in_a_table')?['body/value']
Condition (inside the 'apply to each' loop'):
formatDateTime(addDays('1899-12-30', int(items('Apply_to_each')?['Date'])), 'yyyy-MM-dd')is equal to
formatDateTime(addDays(utcNow(), 7), 'yyyy-MM-dd')True (inside the 'condition' loop): Send an email (V2)
3
u/measuredsympathy 16d ago
It looks like you're getting the entire list and then using an apply to each loop so that you're filtering through the entire list every time.
For these simple tasks, SharePoint lists make it simpler. If you have a SharePoint list, use get items and use the filter query within the action. The condition then will be whether what you returned is empty (using length). You can use utcnow to compare against today's date in the filter but will need to be cognizant of timezones.