The Compose action
Updated: Apr 1, 2020
Microsoft Power Automate (aka Microsoft Flow) provides lots of action steps out of the box. My favourite one is Compose. What does it do?
What is the Compose action?
The Compose action is like a static variable. It can be placed anywhere within your flow, and its value can be accessed from anywhere within the flow.
The value is persistent – once it is set it cannot be changed. The value of the Compose action can be the result of an expression, or be a ‘regular’ value that you assign yourself (e.g. a string, integer etc).
How we can use the Compose action
This action will output today’s date. The expression I am using as the input is:
If we run this, we will see:
Now let us try using a Compose action inside of a loop.
First we declare a new Compose action (Compose 2) using the expression addDays(utcNow(), 1, 'dd-MM-yyyy'). This will output tomorrow’s date.
Next we also declare a Boolean variable (named Stop) to stop the loop after one iteration.
Our flow now looks like this:
Running it gives us this output:
Now we will extend our flow to use the output of both Compose actions. Note how one Compose action is inside of the Do-while loop, and one is outside. The output of either one can be accessed from anywhere in our flow.
Please note how the Compose 3 action (outside of the loop) is set to the output of Compose 2 (which is inside of the loop)!
Here is the output of the completed flow: