Skip to main content

How to Use the Compose Action in Power Automate

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

Compose holds a value for the rest of the flow: a number, some text, or a whole JSON document. Later actions use it as Outputs. It's the simplest way to keep a flow's settings in one place, and this guide uses it for exactly that.

Prerequisites​

The example is List definitions from the setup flow in Part 11 of the Career Development Plan series: a JSON array that describes the two SharePoint lists the flow creates.

Step 1: Add Compose​

Select the + where the action should go, then Add an action. Search for Compose and select it under Data Operation:

The Add an action pane with Compose typed in the search box and the Compose action under Data Operation outlined in red

Step 2: Rename It​

Select the name at the top of the action's pane, Compose, and type a name that says what it holds, here List definitions.

Rename it before other steps use it. Expressions refer to an action by its name, with underscores for spaces, so the output of List definitions is:

Expression
outputs('List_definitions')

Step 3: Enter the Value​

Type or paste the value into Inputs. For JSON, paste the whole document. Here's the start of the setup flow's, with one list and its first column:

Inputs (start)
[
{
"title": "RoleCompetencies",
"description": "Competencies and expected levels for each job title. Used by the Career Development Plan app.",
"noCrawl": false,
"columns": [
{
"name": "Competency",
"schemaXml": "<Field Type='Text' Name='Competency' StaticName='Competency' DisplayName='Competency' Description='The name of the competency, such as Customer skill or Leadership.' Required='TRUE' MaxLength='255' />"
}
]
}
]

Part 11 has the complete array, with both lists and all 16 columns. In the designer, the pane shows it as you pasted it:

The List definitions Compose action's Inputs showing the JSON array, starting with the RoleCompetencies list's title, description, noCrawl false and its first columns with their schemaXml

Keep the JSON valid: double quotes around names and text, and commas between items. In the example, the XML inside each schemaXml uses single quotes, so it doesn't clash with the JSON's double quotes.

Step 4: Use the Output​

Later actions find the value as Outputs under List definitions in dynamic content. Apply to each uses it to loop over the lists (How to Loop Through an Array with Apply to Each):

The For each list loop with Select an output from previous steps set to the Outputs token of List definitions

Because the text was valid JSON, the loop received an array of two items, one per list. In the test run, the loop's inputs listed 0.title as RoleCompetencies.

Common Mistakes​

MistakeWhat happensDo this instead
Renaming after other steps use itTheir expressions point to the old nameRename it first
Invalid JSONLater steps can't read it as an arrayCheck quotes and commas
Double quotes inside a JSON stringThe JSON breaksUse single quotes inside, as the XML does here

Troubleshooting​

SymptomLikely causeFix
A loop over Outputs failsThe value isn't an arrayCheck the JSON starts with [ and is valid
Outputs isn't in dynamic contentYou're in a step above the ComposeUse it only in steps after it

FAQ​

Why Compose and not a variable?​

A variable is for a value that changes during the run. This list never does, and Compose needs no Initialize variable step.

How big can the value be?​

The setup flow's array is about 5 KB, which was no problem. For very large data, keep it somewhere else, such as a file or a list.

Conclusion​

Add Compose, rename it before anything uses it, paste the value into Inputs, and use Outputs in later steps or outputs('Your_name') in expressions. Valid JSON arrives as JSON, ready to loop over.

Additional Resources​

Stay Updated

Subscribe to our newsletter for the latest tutorials, tech insights, and developer news.

By subscribing, you agree to our privacy policy. Unsubscribe at any time.