Power Community

Power Community

Use ParseJSON in PowerApps to retrieve data from Power Automate

Use ParseJSON in PowerApps to retrieve data from Power Automate Microsoft Power Apps, Microsoft Power Automate image 46

Recently a new ParseJSON feature was added to Power Apps. ParseJSON is possibly one of the most complex functions available in Power Apps. in this post some help!

ParseJSON Introduction

Imagine that we have a flow that sends data back to a Power App using a text property in the Respond to a PowerApp or flow action.

Use ParseJSON in PowerApps to retrieve data from Power Automate Microsoft Power Apps, Microsoft Power Automate image 45

But rather than creating multiple fields we return everything as a single text property. Now the app will receive a text that contains the above json.

But it will retrieve it as a text rather than a json object. We can now use the ParseJSON Function to get the details.

So how does ParseJSON work?

In the below example you can see the ParseJSON action is use. My Get Record button, runs my flow and retrieves a text containing my json object.

ParseJSON function in Power Apps

The MyRecord result is a text variable, but the ParseJSON turns this into an untypedObject. What is an Untyped Object I hear you ask. An Untyped Object is the big unknown here. We don’t know what it looks like. however there are properties within the untyped object. In the above example I can get to the Code property, but I can’t use it until it is converted to a number using the Value function.

Conversion functions

To convert unknown objects to typed data we have the following functions available in Power Apps:

  • Boolean
  • ColorValue
  • Value
  • DateValue
  • GUID
  • Text
  • Table

So far we have seen the simple conversion of simple types, like text and numbers and dates. But what is there is a further data structure that we want to get to?

In the above example we saw the Details property actually giving us a full object. But how do we get to for example the Title property?

We can only use each of the properties that exist in the data. Therefore something like this will work. Once we have included the Text function we can now use the Title in for example a label or an input box.

Text(ParseJSON(myRecord.result).Details.Title)

Notice that it isn’t possible to get full Objects. It would be nice if there was a conversion action that did similar things to the Parse JSON action in Power Automate. This Object would need to have the schema for the data supplied but Object Conversion would make things a lot easier. Maybe something for the future. I created an Idea for this on the Power Users Forms, please upvote this.

This post was originally published on this site

- Advertisement -spot_img

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

Enable Early Access Wave 1 2023 | Power Platform

Like every 6 months, enabling Early Access is one of the best things to look forward to as Microsoft...

More Articles Like This

- Advertisement -spot_img