Return Arrays from Power Automate to Power Apps without a premium licence Microsoft Office 365 image 10

When you want to return arrays from a flow in Power Automate to an app in Power Apps you could use the Response action, however this requires a premium connector

Return Arrays from Power Automate to Power Apps without a premium licence Microsoft Office 365 image 6

Avoiding the premium licences

First of all if your flow really uses premium features then just get that premium licence in place, but if you don’t use any other premium features then you might want to use the method described in this post to avoid the costs of a premium licence.

In my case my client wanted to display documents in a a document library and enable the management of document versions inside an app.

Building the flow

So I started by creating a flow that asks for the ID of a document and then all the versions are returned by the REST API call following.

Return Arrays from Power Automate to Power Apps without a premium licence Microsoft Office 365 image 8

The above returns potentially a lot of data that we want to send to the app.

The data that we get returned will need to be reshaped using the apply to each with a compose action side. Simply create a list of fields returned by the Apply to each and separate them by something that you would never find in the data. I’m using ### in this case.

Return Arrays from Power Automate to Power Apps without a premium licence Microsoft Office 365 image 9

Now we just need to return this to the app:

Return Arrays from Power Automate to Power Apps without a premium licence
In the Respond to a Power App action we use the following expression
join(outputs('Compose'),'##Version##')

This will now give us an array of data where each item is separated by ##Version## and each field is separated by ###

Using the data in the app

Now within the app we can create a gallery that has the following items code:

colVersionHistory

And use some code to set this collection using the following one liner

ClearCollect(colVersionHistory, Split(Getversionsofdocuments.Run(ThisItem.ID).result,”##Version##”).Result);

Then for each field we want to display inside the gallery

Index(Split(ThisItem.Result,"###").Result,1).Result

The above will get the first field. To get the second field simply replace the 1 with a 2 and so on.

And that is it. An easy way to send arrays of data back to your app.

Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using contact@veenstra.me.uk.

Leave a Reply

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

%d bloggers like this: