Hybrid workplaces, flexible working hours, and digitalization bring more and more challenges. One of them is approval flows. Approval flows can be simple when a manager needs to approve a document or a vacation for an employee, but most of the time they require multi level approval flows. The fun begins when a document needs to be approved across departments from several managers in the company hierarchy. And it gets even more complicated when the approver leaves the company or takes emergency sick leave.
We all need a hero, too, or service to save the day. Our hero is Power Automate.
But like any other hero, it comes with one small limitation, the flow maximum timeout is 30 days. That means the flow will stop at the action that needs more than 30 days to execute and not continue. The flow needs some trigger to continue, before timeout, and should not resent Approval to the departments that already approved the document.
That is when we come to solve the problem.
We begin by creating a flow that is triggered by a file being created in a SharePoint document library.
After we collect the necessary data from the newly created file, we send an HTTP POST request containing all the necessary data and an additional Approval Flag which contains a value of “0” to our main flow.
When the initial flow ends successfully, the main flow is instantly triggered, and all the data in the HTTP request is transferred.
Before we begin with the approval process, we first need to check if the relevant department has previously approved this request. This is done by checking the approval flag contained in the HTTP request, if it has a value of 0, this means that no department has approved it yet, if it has a value of 1, this means that the hypothetical Production department has failed to approve it, and that approval step needs to be redone, the value of 2 means Production has successfully approved it, while Management has failed to, and so on. Every subsequent department increments the approval flag by 1.
The approval action is set to timeout in 29 days, after which a HTTP action is triggered where we send the data of the SharePoint file, along with the Approval flag associated with the department, and an approval outcome of every previous Approval. While a new flow is initiated, the current flow is terminated.