cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vangrieg
Advocate I
Advocate I

How to populate controls by values from a JSON formatted string?

I have a SharePoint list with some project data. Some projects have an arbitrary number of intermediate milestones. I need to store some information about these milestones in the list, and use a PowerApps form for editing and creating items in this list. 

 

The data itself is very simple, just a milestone name, a date, and a numeric value. Using text input boxes and date pickers...

 

Screenshot (21).png

 

I can easily create records like this: 

 

 

{
    "Milestones": [
        {
            "Name": "Milestone 1",
            "Date": "12/31/2018",
            "Value": 5000000
        },
        {
            "Name": "Milestone 2",
            "Date": "2/1/2019",
            "Value": 5000
        }
    ]
}

 

... and store them in SharePoint Multiline Text fields. However, I cannot figure out how to use this data to edit entries - I need to parse JSON, extract relevant values and populate the controls with them when the form is in Edit mode. 

 

Any ideas? 

 

Thanks a lot in advance! 

13 REPLIES 13

Hi guys, I was monitoring this thread for info as I have a similar use case. Figured it out and posted solution here:

 

https://powerusers.microsoft.com/t5/Creating-Apps/Parse-JSON-in-PowerApps/td-p/168884

I haven't yet worked through pushing the collection back to JSON > SharePoint field (presume Concat, or the JSON function), but will post that step once I have. If anyone wants to jump in, that'd be great!

Anonymous
Not applicable

Hi @humanshield ,

Could you please share your approach in this thread? Not sure why, but when I  click on the link it gives an access denied message.

 

I get the same access denied - hope this is not just a tease. 🙂

TiagoFreire
Kudo Kingpin
Kudo Kingpin

AFAIK there is not yet a Parse JSON command in PowerApps. 

But there is one in Power Automate (formerly Microsoft Flow).

 

It will give you a layer of indirection, but you will get a structured response. 

 

You can call a Power Automate command that:

1) reads from your SP list items that have JSON data,
2) Parse JSON on your list items of interest

3) Builds the return value to PowerApps with a HTTP Response that contains a valid schema for your data. 

 

This will let you Collect() information with a nested object structure in PowerApps.

 

Be aware that depending on the amount of data, including nested objects, you might have an expensive/slow Collection, and that may require you to do strategies to cache and update only the changed rows, instead of ClearCollect()ing every time. 

 

Depending on the amount of data, if you find that the performance is suffering, it may be necessary to bring in a more powerful DB, like Cosmos DB. The same steps above would also be necessary to treat CosmosDB data to be consumed by PowerApps. 

 

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,757)