web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Cannot ParseJSON Corre...
Power Apps
Suggested Answer

Cannot ParseJSON Correctly from Dataverse

(0) ShareShare
ReportReport
Posted on by
I have a collection called colFields and it has an array of general fields that are constant across each item but I have an entry that is called FieldOptions that has records and tables nested inside. When I was done editing the collection, I wanted to upload to my Dataverse table via a JSON string and store it in a plain text, multiline text column. The problem is that no matter what I do, it seems I cannot recreate my original colFields by parsing the FieldOptions entry. 

Here are some examples of the patches to my colFields collection for certain gallery items.

Control for a Text Input Block
Collect(
            colFields,
            {
                ScreenCode: ctxSelectedScreen.ScreenCode,
                FieldType: ThisItem.Text,
                FieldCode: GUID(),
                Icon: ThisItem.Icon,
                Order: CountRows(Filter(colFields, ScreenCode = ctxSelectedScreen.ScreenCode))+1,
                Text: ThisItem.Text,
                Required: false,
                FieldOptions: {
                    Style: "Single Line",   // Single Line | Multiline
                    Format: "Text",         // Text | Number
                    Default: "",
                    ReadOnly: false
                }
            }
        )

Control for a Multiple Choice Field
Collect(
            colFields,
            {
                ScreenCode: ctxSelectedScreen.ScreenCode,
                FieldType: ThisItem.Text,
                FieldCode: GUID(),
                Icon: ThisItem.Icon,
                Order: CountRows(Filter(colFields, ScreenCode = ctxSelectedScreen.ScreenCode))+1,
                Text: ThisItem.Text,
                Required: false,
                FieldOptions: {
                    Choices: Clear(Table({Value: ""}))
                }
            }
        ),
 
I have patched a Multiple Choice Field to my Dataverse table and now I essentially want to take the Dataverse table and use it somewhere else. The I want to decode the FieldOptions entry and use it as a table for the Multiple Choice field. 

This is what the entry looks like in Dataverse

{"Choices":[{"Value":"Item 1"},{"Value":"Item 2"},{"Value":"Item 3"},{"Value":"Item 4"}]}

 
How can I take this item in a gallery, decode it, and use it in control options?
I have the same question (0)
  • Suggested answer
    WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
    Assuming that the FieldOptions value is in the gallery, try this
    ForAll(
       ParseJSON(ThisItem.FieldOptions).Choices As _Items,
       {Value: _Items.Value}
    )
    
     
    Please ✅ Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like ♥
    Visit my blog
    Practical Power Apps    LinkedIn  
  • CL-15011945-0 Profile Picture
    on at
    I tried and this is what I got. 



    FieldOptions will be in a gallery, but what I was hoping to do was essentially reconstruct the initial collection colFields from the dataverse table. Granted I know this is a jank solution but I was asking Copilot for help earlier and this is what it left me off on. Just trying anything at this point. I've tried ParseJSON; I have tried wrapping it in PlainText() and things like that it still doesn't work for me. I don't know if there is a setting I need to know about or I just simply don't understand how this works.
     
    ClearCollect(
        colTestFields,
        ForAll(
            FormFields As f,
                {
                    ScreenCode: f.ScreenCode,
                    FieldType: f.FieldType,
                    FieldCode: f.FieldCode,
                    Text: f.Text,
                    FieldOptions: {
                        Choices: ForAll(
                            If(IsBlank(ParseJSON(If(IsBlank(PlainText(f.FieldOptions)), "{}", PlainText(f.FieldOptions))).Choices), Table(), ParseJSON(If(IsBlank(PlainText(f.FieldOptions)), "{}", PlainText(f.FieldOptions))).Choices) As c,
                            {Value: Text(c.Value)}
                        )
                    }
                }
            )
        )
  • WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
    Firstly a test model below - control is a Label, but a Text Input works as well
     
     
     
     
    The example is in a Gallery, but works on a Form as well. One initial quesiton though - when you display the target text in a field, does it look like the above (are all the commas there) ?
     
    Please ✅ Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like ♥
    Visit my blog
    Practical Power Apps    LinkedIn  
     
     
  • Power Platform 1919 Profile Picture
    2,254 Super User 2026 Season 1 on at
    Hi ,
    Just adding to @ response,
    You can try this method also.
    Alter the code as per your requirements:

     
    Power Fx code :
    With(
        {Raw_data: "{""Choices"":[{""Value"":""Item 1""},{""Value"":""Item 2""},{""Value"":""Item 3""},{""Value"":""Item 4""}]}"},
        With(
            {Data: Table(ParseJSON(Raw_data).Choices)},
            DropColumns(
                AddColumns(
                    Data,
                    field_Value,
                    Text(Value.Value)
                ),
                Value
            )
        )
    )
     
  • WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
    A quick follow-up to see if you received the answer you were looking for. Happy to assist further if not.
     
    Please ✅ Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like â™¥
    Visit my blog
    Practical Power Apps    LinkedIn   

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard