PowerAutomate and JSON extend PowerApps

Extending PowerApps with the use of PowerAutomate and JSON Responses, This is going to be a quick one for a Friday Night as I have been asked this question quite a few times in the past week so time to make a blog post.

As we discussed in our last blog post on JSON (See it here: PowerPlatform and NSC Love JSON) We know how to handle Arrays, objects and multiple data types but how do we get that useful data back to PowerApps!

Well many of your may know the connector. “Respond to PowerApps”

respond to PowerApps or PowerAutomate

Now with this guy, there is one glaring issue. Its TEXT ONLY! Now I don’t know about you… but we have made this work passing things other than text… Lets not go back there.. or mention it again….

However have no fear! We can use something called a HTTP Response. Now the beautiful thing about this response action is that we can define the expected output of data. If we need PowerApps to see an Array… Great! We can build a Schema to send that off.

Now this sounds scary once again… its adding code to your no to low code solution but hang in there with me.. PowerAutomate pretty much does it for you.

In this blog I will be using a SharePoint list as my data source…. But it could be anything.

The PowerAutomate Setup!

The First thing you are going to want to do is create a very basic flow. This is so that we can gather the expected output of your data. This flow launches from PowerApps.

(Using Test in the top right allows you to fire this off as if you were in PowerApps)

basic PowerAutomate Workflow

Running this flow will give us this lovely output that we need to generate our response!

PowerAutomate SharePoint Response

The bit we are after is everything under after the { “value”: make sure you include and copy the open and close square brackets! [ ]

Keep this copy aside somewhere… We will need it soon!

Now your response will be very different to mine so there is no point pasting mine here. However what you need to take away here is you can remove columns by removing their names. For example you see “@odata.etag”: I don’t want this column to appear so when I generate my schema I am going to leave it out.

Finally… The PowerAutomate Reponse!

We are going to add one step to our flow. 
PowerAutomate Response

Ensure you have chosen your body value from the step above. Essentially this is where the response will be getting its data from.

The last step. Click Generate from sample and paste in the entire JSON output from your Get SharePoint List items Connector (In my case)

What this will do is then generate a schema which will format the data and types that will be sent back to PowerApps as seen below:

PowerAutomate Resposne Schema

Now three things I would like to mention here to help some heart ache.

  1. Make sure you define types for everything in your response. PowerApps hates undefined types
  2. Make sure your required items in your Schema will always have data in them
  3. Finally if you change your schema after the PowerAutomate Workflow is added to PowerApps… You have to remove and re-add it… Otherwise it will always expect the original schema.

On PowerApps end your code on your button will look something like this:

ClearCollect(tableFromResponse, getData.run())

All this does is collects your output of the PowerAutomate Workflow into a collection to be used in PowerApps!

And with that. Have a fantastic Weekend!

Ben Out!

Reach out to the team on Twitter at NextStep Aus and let us know what you’ve built!

Check out some of our other posts here:
PowerAutomate QuickBits 2 – Handling APIs Efficiently
Running SQL Queries in PowerApps
PowerApps QuickBits – Radio Button Reset Solution