In this post, weâll take a look at the handy compose action, which is one of the data operations, in Power Automate! Stay tuned to hear about 4 other data operations in Power Automate coming this weekâŚ
UpcomingâŚ
Tuesday 24-01-23 â Join
Wednesday 25-01-23 â Select
Thursday 26-01-23 â Filter array
Friday 27-01-23 â Create CSV & HTML Tables
What is the compose action?
The compose action is one of the data operations we can use in Power Automate. Itâs typeless, meaning we can provide it with any type of data as an input, and it will give us back an output after doing anything we ask it to with things like expressions. Compose will effectively tell us what the output will be of some content we give it. If we give it something hard coded as an input, it will simply give us the same thing back. Though, if we use things like dynamic content or expressions in our compose, the outputs of our compose will be the result of whatever that dynamic content or expression is.
The difference against variables and when to use Compose
Variables can be initialised then repeatedly updated in our flow. Compose doesnât do the same thing. When you have a value that needs to be set once and accessed from anywhere within your flow below your âsettingâ action, this is when to use a compose. Compose is almost like a constant variable (if comparing to a language like JavaScript), it can only be set once, and cannot be changed after, until of course the flow is run again with new data.
Debugging
A great reason to use compose is to make debugging easier when reviewing your flow runs. Occasionally we have actions in Power Automate that wonât show us their outputs. For example if we use a condition and use an expression in that condition, the output of it will only ever be true or false as to whether our provided value met the condition we specified or not.
By using a compose prior to that to hold our value, we can see the data that was actually used in our comparison once it got to our condition step. This makes finding those things going wrong much easier when debugging our flows.
Where to find compose?
In your Power Automate cloud flow, add a new action. You can now either search for compose, or navigate to the built in connectors/steps, then select âData Operationâ, and finally select âcomposeâ.
A problemâŚ
Now say for example youâre using a handful of compose actions to see what youâre getting as an output after using some dynamic content or when using an expression, and youâve referenced all of your compose actions in places in your flow, but now all of those bits of dynamic content all just say âOutputsâ
This makes it a little difficult to easily see what weâve done in our flow without having to hover over every bit of dynamic content from a compose action to see which compose itâs referencing.
So⌠thereâs a little tip my community friend and colleague, Pieter Veenstra, taught me.
If we create a JSON object in our compose action and make what we first intended to put in that action as a value against a field, then we can query our object in a further place in our flow and the dynamic content will show the field name (or as much as it can fit in), which can help to give a preview of what that piece of dynamic content is holding without having to hover and wait for a tooltip to appear!
In your compose action, create a JSON object using {}. Inside those curly brackets define column names inside ââ followed by : and their value. If the value is a string make sure you put it inside ââ.
Now in my future input which could be another compose or an action using a data connector, Iâm going to use this expression to reference the example above.
outputs('Compose')?['MyColumn']
Now if we look at the dynamic content after refreshing our flow, you can see the column name there. This just helps to identify what is being held in our compose.
Now if we look at a flow run to see that the outputs are as weâre expecting here⌠you can see everything is working in the same way as if we just used a compose with the value inside it.
I hope this post helped you to understand how the compose action can be used in Power Automate! If you need any more help with understanding this, let me know.