cancel
Showing results for 
Search instead for 
Did you mean: 

Perform Flow actions further than 30 days from now

I was recently working with someone who had training events entered in a SharePoint list, and who needed to begin a series of actions when the event was imminent. The tricky bit was that the events might be planned as much as 9 months out, meaning we couldn't use the creation of the list item as a Flow trigger, since currently a Flow can only run for 30 days. Following is the solution I came up with, which works well, at least for a fairly short list of items as this scenario involved.

 

In this scenario, instructors would fill out a Microsoft Forms form to request an event at some future date, and then after some initial actions, the only thing that would happen for a while is that the appropriate people would receive an Excel spreadsheet each week listing upcoming events (another topic for another day). So the organizers would be preparing based on this weekly list. Then the day before a given event, things would move into high gear, with various people receiving reminder notifications the day prior, the day of, and a feedback form the day after. But all of this might take place up to 9 months after the event was initially requested.

 

To handle this, I first added a toggle field to the event list in SharePoint: a yes/no (Boolean) column named NearTerm. The idea of this field is that it indicates whether an event is due to occur some time within the next week (actually, 8 days, since a reminder email goes out the day prior to the event). The default value is set to No, as in this scenario it would never be the case that an event would be requested less than a week in advance. So when a request Form is submitted, an item in the SharePoint list is created and some people are notified. This is the Flow which handles that:Event form submission.png

 

Flow #2 runs weekly to email the Excel report to the appropriate people, but the other thing it does is set the NearTerm toggle on items which are coming up within the next 8 days. The first part of this Flow (below) uses the Schedule - Recurrence trigger to run once a week, gets the content of the Excel file, and emails it as an attachment. Next it iterates through the event list (which as I said is not a huge list), and for each item in the list, it checks whether the EventDate is less than or equal to 8 days from now, and if so, it sets the NearTerm to Yes.Weekly event update - Part 1.png

 

Weekly event update - Part 2.png

 Tip: to create the condition

@lessOrEquals(items('Apply_to_each')?['EventDate'], addDays(utcNow(), 8))

I first used the Basic mode, and then tweaked it in Advanced mode. That is, I selected EventDate from the Dynamic data fields, and created the addDays expression in the Expression Builder, but since there's no "Less than or equal to" option in the condition comparison, I had to switch to Advanced mode to change the default Equals to lessOrEquals.

 

And lastly, Flow #3 triggers when an item is created or modified, and checks whether NearTerm is true, which would mean the event is now imminent. It then delays until the day prior to the EventDate, and begins the required notification process. (In my Flow I just have stubbed in one email per notification date, but there was actually more to it in the scenario.)Send event reminders.png

 So essentially, the weekly Flow sets the NearTerm toggle when it actually IS near term, which triggers the final Flow for actions occurring around the time of the event. This means events can be scheduled more than 30 days away, but since the final Flow isn't triggered until closer to the event, the 30-day limitation isn't relevant.

 

 

I hope this may help you in some similar scenario!

Comments

This is awesome Sandy! Thanks! 

 

I am totally going to use this!

It was brought to my attention that it's not obvious what I'm doing in the Delay Until actions to delay, for example, until 1 day prior to the event...

So, for the Delay Until one day before the event, I used:

addDays(triggerBody()?['EventDate'],-1)
(EventDate is my dynamic content date field from my SharePoint list)
The trick there is to use the addDays function in Expressions, but "add" minus 1 to get the day BEFORE 🙂
AND the other trick is that I added a Z after the expression, because the Delay Until input must be in timestamp format. So it looks like this in the Flow:

Delay Until 1 day prior.png

 

Note that I like to add a comment to actions that contain expressions, so I can read them at a glance rather than needing to open up the expression - just a way of documenting for my future self 🙂
 
Then the action that delays until the event date,just uses the EventDate field, with a Z after it, and the one that delays until 7 days after, is similar to above, just adding 7 days instead of -1.
 
Hope this helps!

 

Could you please explain why there is the option to use 'Months' as the unit of time when setting a Delay action if Flows will only execute for a maximum of 30 days?

Meet Our Blog Authors
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • SharePoint, Microsoft 365 and Power Platform Developer | Contributor on SharePoint StackExchange
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 12 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #Office365 #MSFlow | C-sharpCorner MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – https://kamdaryash.wordpress.com Youtube channel - https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ/