“Can I send multiple reminders months/weeks/days before a date with a single Power Automate flow, without repeating the actions?”
When you build a reminder flow, you define also timing of the reminder. Should it send the reminder a month, a week, a day before, or at the date? Each such reminder will need its own Filter Query to calculate if “today” is the date. But what if it’s not a single reminder, but multiple reminders when the date approaches? First reminder 2 months before the date, then 1 month, 2 weeks, 1 week, 2 days, etc…? You don’t want to build the same reminder flow over and over again, changing only the Filter Query. And you don’t have to.
Create an array with configuration
Instead of repeating all the actions, you can have them only once in the flow inside ‘Apply to each’ and change only their configuration. This approach uses the standard array functionality: if you have an array, you can process all the items inside one by one. And in this solution the items represent each of the reminder periods.
Let’s build a fancy reminder flow, where each reminder will have it’s own message and it’ll use the real time period (not a fixed number of days). The first step is to initialize an array variable with the configuration in the format below. Each reminder will have defined the time period, amount of that time period, and the reminder text, e.g.
[
{
"Period": "Month",
"Number": "2",
"Desc": "in 2 months"
},
{
"Period": "Week",
"Number": "1",
"Desc": "in a week"
},
{
...
}
]
Since it should use the actual time period, the solution will use addToTime(…) expression. The allowed periods for addToTime(…) are Second, Minute, Hour, Day, Week, Month or Year.
Loop through the array
Once the array is ready, you’ll loop through it to process the reminder periods one by one. Add ‘Apply to each’ to the flow and select the variable as the input, and then add ‘Get items’ inside.
And here comes the most complicated part of the solution, to build the dynamic Filter Query. Power Automate will show you the ‘Current item’ from the array as a dynamic content, but you can’t use it directly.
You could do that if the variable was initialized as a simple array, e.g. [“1″,”2″,”3”], but in this solution the array contains objects. Using ‘Current item’ would give you the whole object, e.g. {“Period”: “Month”,”Number”: “2”,”Desc”: “in 2 months”}. That’d be never equal to a date column.
You’ll need to manually enter the specific values in the object. In the same way as when processing JSON, you’ll access them using the item()?[‘key’] expression.
item()?['Period'] will give you the currently processed period
item()?['Number'] will give you the currently processed number
item()?['Desc'] will give you the currently processed description
With this knowledge you can build the Filter Query to filter the specific time period in each loop. As already mentioned, use the addToTime(…) expression on the right side.
addToTime([Date], [number], '[units]', '[format]')
replacing the parameters with the actual expressions:
addToTime(utcNow(), int(item()?['Number']), item()?['Period'], 'yyyy-MM-dd')
it'll calculate a date 2 months from today in the first loop:
addToTime(utcNow(), 2, 'Month', 'yyyy-MM-dd')
The output of ‘Get items’ in each loop will be only the items for the specific reminder. You can take them, use the description from the array, format the data in an HTML table and send them in an email. Or group the items together to send each user only one email.
Summary
The concepts in this post are not limited to this single Power Automate flow to send multiple reminders. The main idea is that you shouldn’t repeat actions in your flow unless it’s necessary. If you repeat the same action, only with slightly different configuration, consider using some configuration array and the ‘Apply to each’.
The configuration can be an array inside the flow (if it’s fixed) or e.g. a SharePoint list. And it doesn’t have to be an array of object as in this post. If you decide to use reminders based on number of days, you can have just a single array with the numbers to loop through and use the addDays(…) expression instead.
Thanks for the very useful post .
I beed your help please, I have a flow for reminder but I was asking if I want to get 2 reminder, one fixed reminder before the due date with one day ” Already done ” . The other reminder i want it to be based on the notifcation period column .
Any help please ?
Hello Amr,
I’d probably add one more column to store how many days are the period, and another flow that would convert the period into days, e.g. if users select ‘Month’, the flow would update number 30 in the new column. You can then use this new column to find the items.
Do you use a Scheduled flow or an Automated cloud flow as the trigger?
Hello Opeyemi,
I always use scheduled flows for reminders. Automated trigger would need some action to happen for the flow to trigger and with reminders there’s no such action.
This is just the approach I need, but would it work using the ‘Outlook send email with options’ action since that action will actually wait for a response before it continues running? Wouldn’t that prevent the flow from doing the next apply to each?
And secondly, if your flow is a scheduled flow, how often would you have it run? Would you just set it to run daily to check your datasource to see what items meets the filter query?
Hello Kim,
I don’t use the email with options as it locks the flow until you get the response, exactly as you said.
My reminders are sent daily – the flow is triggered once a day to send the email.