Create Subflow in Power Automate Desktop

by

What is Main flow & Sub flow ?

Power Automate Desktop Flow consists of

  • Main Flow is the flow that is created automaticcally when we build a flow
  • Sub Flow is the flow that users can create to organize the work of the flow.

Main Flow will create automatically when we build a desktop flow as per below image:

Main Flow

We can create “Sub Flow” by click Subflows > New subflow and invoke through Run Subflow action

New Subflow

In this article, I would like to use an example of flow that was previously written in Read Excel with Power Automate Desktop to write more easily. (Usually writing a subflow is used in cases where the robot’s workflow is more complicated.)

From the above article, the main flow consists of actions as per below image

Desktop Flow from old article

Create Subflow

In this article we will separate actions of each software (Excel, Notepad) to the subflow and add the flow for set variables.

Create Subflow 1 : Click Subflows > New subflow and name as ReadExcel

Subflow 1

Create Subflow 2: Click Subflows > New subflow and name as WriteTextToFile

Subflow 2

Drag the actions of Excel and drop to Subflow 1 (ReadExcel), then drag the action of Text File to Subflow 2 (WriteTextToFile)

At main flow, add action Run Subflow to the workspace and select subflow that you want to invoke

Run Subflow action

How to add subflow

Create Subflow 3: Click Subflows > New subflow and name as SetVariables

  • Drag action “Set variable” to workspace and name as ExcelPath, then paste Excel path in the value
  • Drag action “Set variable” to workspace and name as TextWritePath then paste text path in the value
SetVariables Subflow

Go to Subflow ReadExcel, revise the Excel path that we hardcode in previous flow to be “ExcelPath” variable

ReadExcel Subflow

Go to Subflow WriteTextToFile, revise the Text file path that we hardcode in previous flow to be “TextWritePath” variable

WriteTextToFile Subflow

At main flow, add action Run Subflow to the workspace and select SetVariables subflow

Main flow

Add Exit Subflow action in every subflow

Advantage of creating Subflow

  1. Make main flow cleaner, easy to understand overall process
  2. Reduce repetitive actions in the main flow by separate the repetitive actions from main flow to subflow, easy to invoke
  3. Subflow can be used as “Branching”, for example in cases where an error occurs and you have to work in another way

Did You Enjoy this Article?

Subscription to get new articles sent to your inbox each week for FREE

Question?

If you have any questions or feedback about this article please leave a message in the comments section below.


Comments

Leave a comment

Subscribe to get new articles sent to your inbox each week for FREE