“I’d like to send the request back and forth, to return it back to previous approval steps etc, how can I do some state machine in Power Automate?”
Some flows are not a simple, straightforward approval process. Sometimes you need more than just approve or reject, but also the ‘return to previous step’ option. How do you build such flow in Power Automate? A flow that doesn’t move only forward, but can occasionally move also backwards? Something like a state machine that can move between different states?
Utilise the infinite trigger loop
While the infinite trigger loop is often a painful issue, when building a state machine it’s quite useful. Since Power Automate doesn’t have a dedicated state machine logic, you’ll have to build it yourself. And for this you can benefit from the infinite trigger loop.
Instead of a real state machine where you can skip between branches, you can build a flow that’ll be started repeatedly. A flow that’ll contain e.g. a switch, and depending on the request status it’ll go through one of the branches. Once the branch is finished, update the item with the new status. The infinite trigger loop will start another instance of the flow, this time going through a different path.
Since it’ll be multiple flows instead of one, you’ll have to store the ‘shared’ information somewhere in the list. But that’s a small downside for being able to go back and forth in your flow.
When building a state machine in Power Automate, you can benefit from the infinite trigger loop – once you update an item, it’ll start another instance of the flow. And since it’s a new instance, it can go any of the available paths, depending on some value. Start the flow, do what’s necessary, and change the status. The flow will run again and do the tasks for this new status.