November 6, 2024

Today I want to answer the common question about long-running Flows. “How can I configure Flow to run for more than 30 days”. But as we already learned in the past, just because there’s a limitation doesn’t mean we can’t do it. It’s all about strategy, so let’s check an example and how to do it.

Example

First, let’s define a straightforward approval process for a development project idea that comes to the IT department to be developed.

As you may have noticed, the overall process is super simplified for what happens in some companies, but it serves our purpose now.

The overall process is based on approvals. Each step goes to a different department to check if everything is correct to go forward. The Finance department to understand if there’s money to support it, the management to understand if there are resources to develop it and if the requirements are correctly defined. After all this, the project is sent to development.

Regardelss on how you implement it, Power Automate works here as the main process orchestrator where emails are sent to the people who need to make decisions whiteout having people sending emails. If you have any process like this, consider automating it to save a lot of time.

Let’s look at two strategies to develop this automation.

The common strategy

The standard strategy is to use the “Approval” action that sends an email with approval buttons to a person or group of people. When someone approves it, another approval process starts until the end, when the project is ready to be implemented. You can even automate the rejections where an email is sent to the person to provide information.

The overall process makes sense, but it has a huge issue. Since we’re waiting for people to do the actions, the Flow may take some time to run until the end. Remember that the Flow will stop on the “approval” action and wait for the answer. For example, if people book meetings to understand some parts of the process before approval, or simply because people are on holiday, a simple approval can take more than one week. Multiply with all actions, then you’re close to the 30 days limit, and the Flow will fail.

If you run into this limitation, your first instinct is to google:

“How to make a Flow run more than 30 days?”

But this is the wrong question in my opinion. Let’s look at a better strategy.

The better strategy for long-running Flows

The better strategy here is divide to conquer. I’m not too fond of long-running Flows for several reasons:

  1. You increase the probability of crashes.
  2. You make them more complex
  3. They are harder to restart if they fail in the middle of the process.

In the above case, think about if the Flow fails in the middle of the process. What can you do? Start the overall approval process again? That’s not good since we will confuse and frustrate the people that aprove it since they need to do their job twice.

But what about if you have multiple Flows and not only one? For example, one per step of the process. Power Automate allows us to call child Flows so we can have a Flow that kicks the process, waits for one approval, and then either finishes with the rejection or calls another Flow for “step 2” of the process. This way:

  1. Your Flows will run fast
  2. You can easily restart a step in case of a failure without the need to start the whole process
  3. Each Flow will take 30 days, so you’re multiplying the time you have for people to answer.
  4. Even if it takes more than 30 days, you can restart the process by calling the Flow step again.

Let’s look at a potential skeleton of the process.

The Flow won’t stop to wait for the Child Flow to finish, so when we call the “Run Child Flow” action, the Flow will finish. We get the first 3 points with this strategy, but what about the last one? We want to restart the process only if there’s a timeout in the approval so we can do the following:

Correct way to Run a Child Flow in Power Automate

Next, we need to tell Power Automate to only run when there’s a “timeout,” meaning that the action ran more than 30 days. Here’s how to do it:

How to configure an action in Power Automate to run when something goes wrong.

Finally, let’s tell Power Automate to run only after a timeout.

Deal with timeouts in Power Automate for long-running Flows.

With this, your Flow will run “normal” when someone answers in time to the approval process but repeats it when someone ignores or doesn’t reply in time.

Final thoughts

I always like to mention that the above strategy won’t be the solution for inaction for people. The system will only work if people approve or reject it, but at least you’ll have a resistant strategy to, even after a timeout, you can restart the process at a specific step and not from the beginning.

I need to find a bell to ring every time I say this, but it’s all about strategy, so as you can see above, with a few minor tweaks, you can have Flows that resist the 30 days rule without being long-running Flows.

Have a suggestion of your own or disagree with something I said? Leave a comment or interact on Twitter and be sure to check out other Power Automate-related articles here.

Photo by Djim Loic on Unsplash

Manuel Gomes

I have 18 years of experience in automation, project management, and development. In addition to that, I have been writing for this website for over 3 years now, providing readers with valuable insights and information. I hope my expertise allows me to create compelling, informative content that resonates with the audience.

View all posts by Manuel Gomes →

7 thoughts on “Power Automate: Long-running Flows

  1. That seems quite nice, but won’t the parent Flow “STEP 1 : MANAGER APPROVAL” expire before the child Flow ? As it’s launched before the child Flow ?

    1. Hi David

      Excellent catch. I need to refactor the article because I put the “Call Child Flow” incorrectly. It should be a parallel branch below the approval. Then the approval would either continue to the next section (the condition branch) or timeout and relaunch it.

      Thanks for catching it. I’ll refactor the article ASAP :).

      Thanks again!

  2. I came up with the same solution with the catching the timeout and firing up another approval notification. The problem I have is the 1st Approval notification is still out there and to the user it looks and behaves correctly but in the backend it doesn’t do anything. What I need to do is to disable/cancel that 1st notification and force them to use the 2nd one. I’m still waiting on Systems to figure that out.

  3. Great article , I was looking for something similar for our colleagues. Although have you updated the article recently? I am not having any success with the “configure run after” as in your screenshots it has one child flow calling it again. I cannot get that to work as in the child flow that times out it returns a failed response not a timeout. The only way it would work if you had the call child flow under the Approval action (which would give a timeout). Any advice would be most appreciated.

  4. Hello, thanks for the contribution, I’ll tell you, I have a main flow where I call the child flow which is an approval, within the child flow (the approval) if the time expires I want to call it again, this is where I implement your advice, but at Save the flow I get an error vote:

    Error requesting xRM API: “Message: Flow client error returned with status code “BadRequest” and details “{“error”:{“code”:”FlowCannotInvokeItself”,”message”:”Could not save flow because streams cannot call themselves as child streams.”}}”. Code: 0x80060467 InnerError: “.

    It tells me that I can’t invoke itself as a child stream. Can you give me a hand please.

    Thanks for your time

    1. Hi Edison,
      Indeed a Flow can’t call itself, but there’s a way around it. You can use the “When a HTTP request is received” trigger instead of the “Manually trigger a Flow”.When you want to call the Flow, you can then use the HTTP action to send a request to the generated URL in the “When a HTTP request is received” trigger. This way, you can trigger a Flow by triggering itself again.
      Unfortunately, it requires premium connectors but that’s the only way I know on how to do it.
      Cheers
      Manuel

  5. Hello,
    Are you using the desktop application or the web application of the Power Automate license in your proposed solution?
    In the case of a web application, a child flow or trigger flow cannot be integrated within an instant flow after a query/condition. The message immediately appears here: “You cannot use this trigger as an action”.
    The same thing happens when I create and integrate this via a solution

Leave a Reply

Your email address will not be published. Required fields are marked *

Mastodon