Edit

Share via


Build readable and maintainable flow scripts

Building flow scripts in Power Automate with clarity and organization improves development efficiency, fosters collaboration, and simplifies troubleshooting. Follow these recommendations to streamline workflows, enhance teamwork, and make scripts easier to manage and scale.

Use consistent naming conventions

Provide descriptive and meaningful names for subflows, variables, UI elements, and images.

For variables (input/output and flow variables):

  • Use camelCase, PascalCase, or underscores to separate words.
  • Add a datatype prefix to variable names.
  • For input/output variables, add a prefix to both the variable name and external name to distinguish them from flow variables and other variables outside the Desktop flow designer.

Screenshot of the variables pane in Desktop flow designer showing use of prefixes in names to distinguish variables.

Follow best practices for cloud flows by learning more about using consistent naming for flow components. Learn more about managing variables and the variables pane in Desktop flow designer.

Add comments

Use the Comment action to add notes in the flow script:

  • Add a comment at the beginning of the Main subflow to introduce the flow. Provide a short description of the process, the intended audience, and related flows.

  • Add comments to explain changes when fixing bugs.

  • Add comments at the beginning of each subflow to describe its purpose.

Screenshot showing how to add comments in a flow script.

Note

Get help adding comments using the Summarize actions & subflows Copilot skill.

Add regions

Use the Region and End region actions to group actions within a subflow logically so they can be expanded or collapsed.

Screenshot of the Region and End region actions in a subflow.

Use modular design and reusable components

Break down your flow into logical modules or sections based on functionality or tasks.

Subflows

Create subflows to group related actions or reusable tasks.

  1. Identify actions that perform a task or need repetition, and group them in a subflow.

    Screenshot of a flow diagram showing subflow creation.

  2. Invoke the subflow with the Run subflow action.

    Screenshot of the Run subflow action.

Learn more about setting up subflows.

Reusable flows

Create reusable flows to simplify complex processes into manageable parts for use in different workflows.

  • Identify flows that can be reused across other desktop flows, and create a dedicated flow to use as a reusable component.
  • Share the reusable flow with other users in an environment.
  • Convert a subflow to a reusable flow by copying and pasting all its actions into the new flow's workspace.
  • Invoke it with the Run desktop flow action as a child desktop flow.

Screenshot of the available desktop flows in the Run desktop flow action.

Learn more about running a desktop flow from other desktop flows.

Follow best practices for cloud flows by learning more about creating reusable code.