• Ajith Madathil

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


Example #1



This action will output today’s date. The expression I am using as the input is:

formatDateTime(utcNow(),'dd-MM-yyyy').


If we run this, we will see:




Example #2


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:



Example #3


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:





2,435 views0 comments

Recent Posts

See All

How to call an API using the Power Automate HTTP action

In this blog post I will access NASA's Astronomy Picture of the Day (APOD) API using Power Automate. The plan is to retrieve the picture of the day using the API and store it in a SharePoint document

Blog Categories
 

Beginner

Intermediate

 

Advanced

Power Automate Essentials

How can I help you?

I am happy to help at any time.  You can contact me via the official PowerAutomate community forum.  Tag me (@abm) on any post you make there if you would like to me take a look at it.

I am always available for both corporate training or 1-2-1 training for individuals.