How to set date for 2 weeks out for an automated reminder
-
08-02-2021 - |
Question
I have a SharePoint list that is populated with ticket data. There are two primary columns "Open Date" and "Calculated Date" I'm trying to figure out how to set the calculated date 2 weeks out from the open date and every two weeks thereafter.
Essentially, I'm using Microsoft flow to automate a process. The flow will check the ticket status if it reads open it will look at the open date and kick an email off two weeks after the open date. For example say ticket 1 is opened as of today 4/16/20, the flow will check the ticket status if it is open it will look at the open date and there will be conditions set to send an email 2 weeks after the open date. However, I will also need it to send an email every two weeks after until its closed. 4/16/20 open date > email 4/30/20 > email 5/14/20 and so on until it's closed.
Essentially, I'm looking for a way to have imported dynamic date data and a calculated date column that always reads two weeks from the imported dynamic date data. For example the imported data would be "last ticket update" ex. it's entered into SharePoint as 4/16/20 I would like another column "calculated date" to be able to change dynamically 2 weeks out from the "last ticket update." A ticket will be entered into SP with a date and status if the status remains open I need the calculated date column to be every two weeks to send a reminder. I hope that helps explain what i'm trying to do.
Solution
You can try setting up your flow like this:
After a new item is added, initialize two variables (ReminderDate
and NextReminder
) that holds the initial value addDays(triggerBody()?['Created'],14)
.
Then, add a Control Action of type Do until with a test on your status column ("Balance equal to 200" in my example). Note that this field should be from the later "Get updated item" action, not the original trigger!
Inside this, insert the Delay until action with the ReminderDate
variable as the timestamp.
Insert a step to get the item (by the ID from the original trigger) so we can know if the status field is changed.
Next, add your notification email, then update the NextReminder
variable to be addDays(variables('ReminderDate'),14)
, finally set the variable ReminderDate
to the value of NextReminder
.
This loop should continue to send an email every two weeks until the ticket status is closed.
Here is my inbox with this flow running with 2 minutes instead of 2 weeks:
More detailed screenshots:
The formula used in the first variable initialization is: addMinutes(triggerBody()?['Created'],2)
In the second variable initialization, it is just set to the value of ReminderDate as it doesn't matter what it is yet.
In the "Do until" step, here I am using a field called "Balance". This is from the "Check the item" step, NOT from the original "When an item is created". This is important.
Final formulas: addMinutes(variables('ReminderDate'),2)
The last variable is set to the value of NextReminder
.