Compose actions inside apply to each steps in Power Automate

Today I came across  a weird feature in Microsoft Flow. I collected a list of files from SharePoint and I was setting a Compose with the title of my files.

Reference Compose inside an apply to each

In the run history each file was listed and I was quite happy with this. Inside the apply to each step can use this value.

Get Files action giving 10 files in compose in Apply to each

But what if I use this outside the Apply to each after the Apply to each has finished. To my surprise I was getting an array back.

Compose following apply to each containing array

My first thought was: “That is annoying. That can’t be right!”

But you could use this to filter your arrays.

Filter array

With the condition set to:

startsWith(outputs('Compose_-_File_name'),'t')

This now resulted in an array just giving me the files starting with the letter t.

However I found that the array returned looked like this:


[null,"text","test2",null,"tf78062375",null,null,null,null,null]

Concurrency

It looks like the compose actions inside the apply to each steps are created as an array. Why?

Although by default the Concurrency is switched of on every Apply to each step. It is possible to enable this.

To make sure that things don’t go wrong you could switch this off, however I have found recently that the order of the items is not affected by the Concurrency feature. Performance wise the concurrency feature can really make a difference.

Concurrency control

The advanced method

Do you want to take this method further, then read The advanced Pieter’s method in Power Automate

6 thoughts on “Compose actions inside apply to each steps in Power Automate

  1. Hi Pieter,

    I am facing a weird scenario where I am using the same functionality but outputs(‘compose’) is giving me null. Is there any specific condition that needs to be fulfilled for outputs(‘compose’) to work after setting in Apply to each loop.

    Thanks

  2. Has this changed? When I try this now, and Compose actions inside an Apply to Each are not available at all outside the loop.

    1. Hi Stuart,

      Within Dynamics content they are not available but if you type in the expression editor the following expression then it will work:

      outputs('name_of_the_action_inside')

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: