As flows grow in complexity, managing a flow’s structure becomes important for fixing issues & testing

The Scope action can be used to help make a flow manageable. Scope is an action that groups other actions within it.  Its purpose can be compared to the Group control in Canvas Apps. A Scope action can be collapsed to make a flow easy to view or expanded to see the actions it contains

Making the number of actions in a Scope too large or too small defeats its purpose. It’s best to think of Scopes as the high-level steps in a flow. Because actions contained in a Scope are all related in some way, use comments to provide information on the collective purpose of the actions in the Scope

Scope Action

power automate scope action

Below the Scope called ‘Scope count rows’ contains 2 actions.  Note that variables can’t be initialized within a scope

Error Handling

A big benefit of using the Scope action is that rather than creating separate error conditions for each individual action, instead, an action can be set to execute if the overall scope fails.  A Scope succeeds if all its constituent actions succeed, but if any one of its actions fail then the Scope action also fails

I’ve demonstrated this below by using the ‘Initialize variable 2’ action to assign the variable varScopeOutput using the ‘result’ function and with the Scope name as its parameter. 

Set the ‘Initialize variable 2’ action to only run when the ‘Scope count rows’ action fails

Running the flow and making sure the ‘Scope count rows’ action fails, produces the result below with the error captured in the variable.  The same technique would be used to initiate specific error actions

scope4

Yet a further benefit is that a Scope and all its actions can be copied and pasted elsewhere in the flow, rather than recreating from scratch

It’s good practice to keep responses at the end of a flow outside a scope, as I have done, so they are easily identifiable

Leave a Comment

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

Scroll to Top