Question

At the moment it is possible to run the same Power Automate workflow on the same SharePoint Library item. (i.e. a 2nd instance of a workclow can be created before the 1st instance has finished). This causes all sorts of problems, nevermind poor user experience. The option of a further workflow needs to be available to run on other items.

In SPD days, the same workflow was prohibited to start on the same item and the start button was disabled.

Concurrency does not solve this one. Any suggestions?

Thanks

No correct solution

OTHER TIPS

There's no direct way to prevent a Flow instance from getting started on an item when an instance is already in progress on the same item. However, I think, we can take a few steps to minimize the chances of having multiple instances of the same flow running on the same item to minimize data corruption.

My test is based on a custom list (Issues) and Power Automate trigger on [For a selected item]. But this can be applicable to Libraries as well with [For a selected file]

Here are the steps that I've tested with:

  1. Add a Yes/No type column, IsWorkFlowRunning, to the list with default value being set to No (false).
  2. Create a flow with [For a selected item] trigger
  3. Add [Get item] and retrieve properties of the item by [ID]
  4. Add a [Condition] to check if [IsWorkflowRunning]=false
  5. If "false", update the item by setting [IsWorkflowRunning]=Yes (true)
  6. Add all the actions needed in the flow to meet business requirements
  7. once everything is done, update the item again by setting [IsWorkflowRunning]=No (false)
  8. Format [IsWorkflowRunning] column by using the following JSON (replace the flow ID).
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "style": {
    "display": "=if([$IsWorkFlowRunning]==false, 'block', 'none')"
  },
  "children": [
    {
      "elmType": "button",
      "txtContent": "Run Workflow",
      "customRowAction": {
        "action": "executeFlow",
        "actionParams": "{\"id\":\"2cc9148a-744d-413c-9e3d-6849a6f00b46\"}"
      }
    }
  ]
}

Expected results:

  1. Button to run the flow on the selecdted item will not be avaialble when [IsWorkflowRunning]="Yes"
  2. Even if the user is able to click the button due to latency, condition in the flow will prevent data from getting corrupted.

Screenshot of List showing JSON formatted button

enter image description here

Screenshot of the Flow

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top