One of the limitations of Power Automate when it comes to automating business processes (which are often long-running human workflows) is that a Flow instance can run only up to 30 days; after 30 days, the Workflow times out. If it is a multi-step approval workflow, all the approvers must complete the processing within 30 days from the time the flow was started to avoid the timeout.
So the question is how we overcome 30 days limitation and run approval workflow for more than 30 days?
An important thing to note here is that a flow may expire after 30 days but any unfinished approvals created by that flow do not expire. Whenever Power Automate creates a new Approval, a unique Approval ID is generated and this ID is stored in the backend Microsoft Dataverse table along with the other details relevant to the newly created approval. We can save this Approval ID somewhere (e.g. in SharePoint), re-trigger the Workflow just before the 30-day timeout period (e.g. on the 28th day) and re-use the Approval ID we saved earlier during the next run of the Flow for the Approval action.
Business use case - When a user uploads a document to a SharePoint document library, the approval workflow must start and require Level 1 and Level 2 approvals; these approvals may take more than 30 days. While the approval workflow is in progress user should not be allowed to edit the document.
STEP 1: Create a Document Library with the following columns
|PendingApprovalID||Single Line of text|
|Initiate WF||Single Line of text|
Require to Check Out settings - Require documents to be checked out before they can be edited? "Yes"
STEP 2: Create Approval Workflow
Now it's time to create the approval workflow. In my Workflow, I used "Create an Approval" and "Wait for an Approval" actions; this allows me to wait for 30 days for an approval request to take action and, if not actioned within 30 days, do the trick before Workflow expired by itself.
I m triggering the Workflow when an Item is Created or Modified in the document library and use the switch action to check the document approval status as shown below.
Under the Workflow trigger conditions, the following conditions are used.
Note – I use a service account to run the Workflow as this allows me to check out the document in to the service account while the workflow is running. So the user wont be able to edit the document as it is checked out to service account.
When a user initially uploads a document, the status column value is always not equal to the "Pending L1 Approval "or "Pending L2 Approval", so this will ensure that initially, Workflow always goes through the default branch.
The default branch is as follows.
The main important element here is to get the Approval ID created under the "Create an approval – Level 1" action and save it in the SharePoint document library as follows.
Now the next challenge is how to terminate Workflow myself before it expires.
In the "Wait for an Approval - Level 1" action, I used the following syntax that will time out the waiting action in 27D23H60M60S, basically the Workflow waiting for 28 days in the wait approval action and Time out by itself.
@concat('P', '27D', 'T', sub(23, int(formatDateTime(convertTimeZone(utcNow(),'UTC','AUS Eastern Standard Time'), 'HH'))), 'H', sub(59,int(formatDateTime(convertTimeZone(utcNow(),'UTC','AUS Eastern Standard Time'), 'mm'))), 'M', sub(59, int(formatDateTime(convertTimeZone(utcNow(),'UTC','AUS Eastern Standard Time'), 'ss'))), 'S')
After the Waiting for an approval action gets timed out, I update the document library “Status” and “InitiateWF” columns, then terminate the Workflow as follows. Once I update the document library, this will trigger the Workflow again based on the trigger condition I discussed in the image 2.
Note –I have used "has time out" and "skips" run after condition as follows.
Then I terminated the workflow as shown below image.
As shown above, image when the document library “Status” column gets updated, the workflow trigger again, but now the “Status” column value is "Pending L1 Approval".
Now, when the Workflow comes to the "Switch – Account – WF Status" action as shown in Image 1, the Workflow navigates to the "Case - Pending Level 1 Approval "branch as shown below.
In this branch, rather than creating an approval for Level 1 again, I used the previous approval ID (which I saved in the document library) and waiting again for Level 1 approval, as shown in the above image.
Make sure to do the same configurations discuss above for Time out and run after settings.
This step will loop through the Level 1 approval until the approval is Approved, rejected or cancelled.
Similarly, you can implement the Level 2 and multilevel approval workflow that can run for more than 30 days.
This is How to run a Power Automate Approval workflow for more than 30 days. More importantly, the flow was implemented without any premium licence and Microsoft 365 Power Automate out of the box actions.