Approval Flow with Weekly Reminder – Getting past 30 Day Limit
Recently I had a fairly complex workflow requirement for a client. They had a SharePoint Online list form which needed an approval process. Luckily, Microsoft Flow’s built in approval workflow makes it very simple to set up an automated approval process.. The complex piece of the puzzle is the notification requirement.
The Workflow Process
This Flow needs to keep checking if a certain field contains a value for an unknown amount of time with two levels of notifications required. The first notification being a one-time notification 2 weeks after the form was approved if the field is empty. The next notification is a recurring weekly notification that should keep running until the field is filled out.
Getting Past the 30 Day Run Limit
One thing that I had to make sure I addressed when designing this Flow is how to get around the 30 day run limit. Depending on how long it takes someone to approve the item and enter a value in the field, the total Flow run could easily surpass 30 days. For those that don’t know, Flow run’s are limited to a maximum 30 day duration. You can find out more about these limits here: https://docs.microsoft.com/en-us/flow/limits-and-config
When I was researching ways to get around the 30 day limit, I came across this great blog by Mikael Svenson – How to Architect Long Running Flows. The concept he listed out in the blog was exactly what I needed to make my Flow work.
The Set Up
In order to handle the workflow requirements, I broke it out into three separate Flow’s:
Flow #1 – Approval Flow
This Flow gets kicked off when a new item is added in the SharePoint list. A basic approval is kicked off and there’s a check to see if the response is approve or reject. If the item is approved, an email is sent out and a status field is set for the item. The last step is the important piece, I’m using the HTTP action to call my second Flow from the approval Flow. The HTTP action should be set up using the POST method and in the body, you would pass in the ID of the item so that we can use that in our second workflow.
Flow #2 – 2 Week Reminder
This Flow gets kicked off after the Approval Flow finishes with an approved response. The trigger for this Flow is “When an HTTP Request is Received”. In the Request Body JSON Schema for the HTTP Request click “Sample Payload”. All we need to get from the HTTP request is the ID of the item in the previous Approval Flow. The JSON Schema for that should be: {“ID”: 1}.
Once this Flow is Triggered, it uses a “Do Until” action with the following advanced expression:
@or(equals(body(‘Get_Items_to_Check_Status’)?[‘Status’]?[‘Value’], ‘Delayed’),not(equals(body(‘Get_Items_to_Check_Status’)?[‘Solution’], null)))
Next, insert a Delay action and set it to 2 weeks. Then, you need to insert a “SharePoint – Get Item” action and pass in the ID from your HTTP Response to get the updated properties for the item.
IMPORTANT NOTE: The expression in your “Do Until” action must reference the Get Item Action INSIDE your Do Until loop, otherwise it won’t work.
After the delay, we need to check to see if there is a solution. If there’s not, then set the status to “Delayed” and if there is send an email and mark the status as complete. The last step of this workflow is to add an HTTP action to call our last Flow that sends out weekly reminders.
Flow #3 – Weekly Reminder
This is the final workflow that will run continuously until the field has a value. The same “When an HTTP Request is Received” Trigger and JSON schema that we used in Flow #2 is used here . Next, add a “Do Until” action that is set to run until the field in question is not null.
By Default, Do Until Actions are limited to 60 iterations and timeout in 1 hour. So, we need to “Change Limits” option and set to the Count to the maximum allowed of 5000 iterations and the timeout PT270H which is 72 hours.
In order to ensure that the Flow doesn’t time out and stop before the field is filled out, we need to add another “HTTP” action with a POST Method that will call the same Flow and kick it off again. You’ll need to put the HTTP action right after the Do Until Loop. You’ll also need to click the dots and “Configure Run After” so that it only runs if the Do Until Times Out.
I’m sure there is an arguably better way to architect this into two and maybe even just one Flow and if you know of a better way please leave a comment and let me know.
HI,
I am very new to Flow and I am trying to understand HTTP action in Flow. My situation is I have 3 approval levels. The entire approval process can take months. When an item is added, it goes to the first approver. If approver 1 approves, then goes to approver 2 and until approver 3 is approved. Each approver can take more than 30 days. What would be the best way you recommend?
For long running approval processes, the best work-around is the self-calling Flow method. In a nutshell, you can configure an Action’s Timeout property in your Flow then configure it’s Run After properties. So we know that Flow’s timeout after 30 days. So you can set the Timeout property to P29D (29 days) so it can perform an action before timing out. You can insert an HTTP Post action and configure it’s run after property to only run if the Flow times out. You can have that HTTP call another Flow which has an HTTP Response trigger that kicks off your approval process again. Micahel Sveson has a good post on how to do this: https://powerusers.microsoft.com/t5/Flow-Cookbook/How-to-architect-long-running-flows-which-exceed-the-30-day/td-p/83138