Send multiple SharePoint reminders in a single Power Automate flow

“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')
Power Automate multiple reminders single flow

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.


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to a special content like a SharePoint Filter Query cheat sheet.

Zero spam, unsubscribe anytime.

Add a Comment

Your email address will not be published. Required fields are marked *