Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

PowerObjects Blog 

for Microsoft Business Applications

|

Send a Collection from Power Apps to Flow

Post Author: Joe D365 |

As you build your Power Platform apps, you probably find yourself in situations where you need to send multiple rows of data from Power Apps to Flow for further processing of that information and to take subsequent steps. Typically, these multiples rows of data are stored in a Collection, so ideally, you would just pass the Collection directly to Flow. We’ll show you how in today’s blogpost.

For the longest time, it was not easy to pass a Collection to a flow. It required some crazy workarounds because Flow accepted only string values as parameter from the app. Because of this limitation, we had to either pass one string value at a time to Flow, which meant that it consumed a run for each string (expensive!), or hard code a certain number of variables that we thought wouldn’t be exceeded, and then pass those many (or less than) string values from the app to Flow. Both workarounds are definitely not what we call good design!

Just recently, however, Microsoft released the JSON function that lets you send an entire Collection to Flow! JSON comes in with the ability to send the whole Collection data as a text string and it takes only a single flow to process all data in the collection we send. In PowerApps, to send the whole Collection as input parameter for the flow, we pass the Collection to the Flow as shown below.

TestpassacollectionfromPowerAppstoFlow.Run(JSON(EmailsCollection,JSONFormat.IndentFour ())

C:Usersthien.doanAppDataLocalPackagesMicrosoft.Office.OneNote_8wekyb3d8bbweTempStatemsohtmlclipclip_image005.png

In the example above, what we want to do is select multiple records and send an email to/for all of them. A typical use case would be emailing a report for all the jobs we have done today. So, what we want to happen is this: on click of the Send email button, we want all the emails from selected records on this gallery to be added to a collection that is then passed to Flow.

Inside the Flow, all we need is another step to parse the JSON with the schema we send from PowerApps.

C:Usersthien.doanAppDataLocalPackagesMicrosoft.Office.OneNote_8wekyb3d8bbweTempStatemsohtmlclipclip_image006.png

One tip to quickly get the schema is creating a trial run to get the EmailCollectionString record of the flow from PowerApps; then use sample payload to generate schema in the Parse JSON step!

C:Usersthien.doanAppDataLocalPackagesMicrosoft.Office.OneNote_8wekyb3d8bbweTempStatemsohtmlclipclip_image007.png

It now takes only a single flow run to send a list of emails to users. Additionally, we are able to use other information that goes along with Email – in this example, Name. You can obviously add any other related information to your collection and pass it to Flow using this method.

Another Use Case

The JSON function can be used not only for passing collections to Flow but also for troubleshooting other issues. For example, if you use the Media control in your app, it returns only a blob url for a photo, which does not allow you to use the photo in any of the ways you would expect. However, the Camera control returns an actual image you can view and store just like any other image. In this scenario, you can use the JSON function to get the value from image data of the AddMedia control via the flow.  The JSON will be able to hold the image data instead of the blob url. See below:

Conclusion

The JSON function can play a vital role if you want to send a large amount of data from Power Apps to Flow. No more workaround or any technical work needed for dealing with larger datasets in Flow. Dont forget to subscribe to our blog for more Power Apps and Flow tips and tricks!

Happy Flowing!

Joe CRM
By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

PowerObjects Recommends