Implementing a State Machine using Microsoft Flow

In the past couple of weeks I’ve been using PowerApps, and the overall experience has been great! SharePoint Designer and InfoPath have been replaced by a browser based application that is a lot easier to work with. Of course it is still all very new but the general experience is very good.

Today, I will be looking at Flow. A Flow can be triggered by a lot of things , but for now I will look at a flow that is triggered by a PowerApp.

In the past I wrote Workflow articles about Nintex Workflow and how to setup the workflows. I have always liked the state machine workflows and I was wondering if I could setup my Flows in a similar way.

So If we start with the basics. Adding some tasks. Within Flow there are a lot of tasks available and for Flows related to PowerApps that use SQL Server as their data source I could imagine that there may be a lot of Update row actions in my flows. Flow supports both on-premises and Azure based SQL installations as the “Connect via on-premise (hic) data gateway” indicates.

For small flows it will be quite easy to just stick action after action. But once a few additional actions are added it might be useful to organize the no-code a bit.


As with Nintex, Microsoft has now introduced comments for each step

This makes the workflows already a lot easier to understand and compared to SharePoint Designer workflows this is already a massive improvement.



Renaming actions

Next to adding comments it might also help to rename all the actions within a flow. This helps documenting the Flow without the real need for additional documentation outside the Flow.



Within Flow it is possible to create variables. So I’m adding a Variables – Initialize variable action to my flow.

Within this action I’m creating a variable State Machine Status

Then I’m adding a Do Until Action

The Do Until action I’m configuring to run until my status variable has been set to Complete.


Then Inside my Do until I create a Switch, which can be found in the … More.

Then by clicking on the + between Case and Default  I add all the different states that I want to go through.

Then for each state I’m added a state change:


Time to add the real work into my Flows and my state machine workflow is ready.


Take Our Poll


Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using

View Comments

  • Tried this, when the workflow enters the "do until" loop, you can't see the state of the flow when its running. Any ideas on how to see the current state?

    • Do you mean the that the State Machine Status isn't visible? This should be created as a variable within your Flow/Logic App.

  • No, I mean that once its running, when its in the do until loop, Microsoft Flow doesn't expand. So its not about the variable, you cannot see the current action the workflow is on - because it just shows the current action as do until.

    So for a production workflow, where the majority of the flow's work is done inside the do until, its not practical, because you no idea what is the current action.

    • I guess you could update a status field in the triggering list item in SharePoint or any other data that may trigger your flow.

      • OK, thats a work around. I'll try it and test. I have a workflow with about 10 tasks, so I'll see if it works.

Recent Posts

Object must implement IConvertible in Power Apps

In Power Apps when you do a Patch to create a new item or to…

3 days ago

Get started with adaptive cards in Power Automate

Getting started with adaptive cards can be difficult. In this post i have written some…

1 week ago

Create PDF documents from data in Power Automate

In this post I will look at how to create PDF documents from data. Use…

1 week ago

Unnest nested arrays in Power Automate

We all know this problem, you have a nested array in Power Automate but how…

3 weeks ago

Advanced settings not loading in Power Platform

Yesterday one of my clients showed me an issues where the Advanced settings didn't load.…

3 weeks ago

1 Better way to use Create Item in SharePoint with Power Automate

Have you been using the REST API instead of the create item action in Power…

4 weeks ago