How To Increase PowerAutomate Timeout For More Than 30 Days

Introduction

  • In this blog, we will see that in PowerAutomate an instance waits for only 30 days. 
  • Sometimes an approval process takes time more than 30 days, in that case, our flow will fail and we need to re-start that flow which is not the expected scenario.
  • So, here we will see how we can continue our running flow instance and make sure it will never timeout. Let's get started.

Pre-Requisites

  • Here, I have one demo list 'Employee Details' as below:
    • You can have all your necessary columns but need to create 2 new columns as below to manage the flow instance.
      1. FlowStatus - Single line of text
        • We will use this column to save the value that flow should run or not.
      2. CurrentCase - Single line of text
        • Please set the default value of this column is 'Case1'. So, when a new item is created it will have a default value as 'Case1'.
        • We will use this column to save the value of the current case that is currently in which stage flow is running.

Motivation

  • Now, we have the list ready and we have a requirement that approval should start when an item gets created.
  • When an item is created it will send an approval to the 2 Approvers.
  • If Approver, does not approve a request within 30 days, that flow instance will be failed So, here we will create a new instance from where the last instance gets timed out for the same item.
  • So, to start the flow again with a new instance we will create a PowerAutomate When an item is created or modified trigger.

PowerAutomate

  • Here, we are creating an automated cloud flow. Next, enter your flow name and select trigger When an item is created or modified, click on 'Create'.

  • Next, select your site address and list. Here, we will add one trigger condition that if FlowStatus is equal to 'No' our flow should not trigger.
  • Initially, FlowStatus value will be null so, the flow will run until we change its value to No.

  • Copy below trigger condition, click on Add and paste there and click on Done.

    @not(equals(triggerBody()?['FlowStatus'],'No'))
     
  • Next, I want to update the Status column value as "In Progress" so, users can know that the approval process started. 
  • As our flow will trigger when an item is created or modified so, please keep note that at any point if you want to update the item and don't want to trigger a new flow instance set FlowStatus column value as "No". So, it will not create a new flow instance for that item.
  • Next, we will add the Switch condition so, based on the CurrentCase column value that Case will run.
  • Here, the default CurrentCase column value is Case1. So, when a new item will be created we will check that in Switch condition and initially, Case 1 will run.


  • In Case1, I need approval from the approvers. So, added Start and Wait for approval action, which will take approval from the approvers.
  • Here, we will need to set a Timeout for approval. As we know flow instance default timeout is 30 days so if in Approval 1, approvers are not taking any action within 30 days it will automatically fail so, here we are adding timeout P29D = 29 Days (PT1M = 1 Minute) to manage that timeout manually and if that approval not approved/rejected within 29 days we will take next action according to that.
  • Next, If approval is approved/rejected, we need to update the Status column value in the list so, I am adding the Update item action for that. Also, simultaneously we need to check that if Approval took more than 29 days, the current flow instance should be completed and a new flow instance should be created.
  • Next, we will add another parallel branch so, it will have all the actions if approval timeout.
  • We will need to change configure run after for the Update item action which we have added in the parallel branch. So, click on 3 dots (ellipsis) and click on "Configure run after" and select "has timed out" and click on the Done button. So, by doing this Update item 3 will only run if Start and wait for an approval time out.


  • Here, if our approval process is completed within 29 days it will run the left branch of update item action and if it timed out it will run the right side of a branch of the update item.
  • If the left branch is executed, it means approval has been completed within 29 days. so, we will update the Status column, set the CurrentCase column value as the next approval Case, and the FlowStatus column value as "Yes"  because we want to trigger a new flow instance for the next approval process.
  • On the right side, if approval timed out, I have set the Status column value as timed out, CurrentCase column value as running Case value, and FlowStatus column value as "Yes", because we want to start the same approval again.
  • Repeat the steps for Case2 as I have 2 levels of approvals. You can repeat for as per your requirements.
  • Make sure in the last Case, when your approvals are completed, set the FlowStatus column value as "No" so, that means your flow is completed. Here, I have set the Status and CurrentCase column values as well.

So, here we have increased the PowerAutomate timeout by more than 30 days which will never get time out.

Let me know if you have any questions or concerns.