Skip to main content

Notifications

Community site session details

Community site session details

Session Id : tnjiyL1lg700DO/pa3QlAi
Power Apps - Building Power Apps
Suggested answer

Filling a Formular Screen with JSON Data

Like (1) ShareShare
ReportReport
Posted on 23 Oct 2024 10:03:15 by 175
Hello,
 
i have a app with a Formular screen, i would like to enable editing the formular, and saving it for later adaptions - as its a huge formular i don't want to save each input in a separate  Column,
so i thought i will save it in JSON-Format in one column.. i now have created a little sandbox, for trial.
it works like a Charme with Checkboxes and Text fields but im struggling with Comboboxes..

I just generated a few input controls and 2 buttons - one to JSON and one To PARSE
 
JSON code:
Set(varFormData; JSON([{
    ComboboxCanvas2_1: ComboboxCanvas2_1.SelectedItems;
    ComboboxCanvas2: ComboboxCanvas2.SelectedItems;
    TextInputCanvas3_2: TextInputCanvas3_2.Value;
    TextInputCanvas3_1: TextInputCanvas3_1.Value;
    TextInputCanvas3: TextInputCanvas3.Value;
    Checkbox2_2: Checkbox2_2.Value;
    Checkbox2_1: Checkbox2_1.Value;
    Checkbox2: Checkbox2.Value
}]; JSONFormat.Compact));;
 
resulting in:
[{"Checkbox2":false,"Checkbox2_1":false,"Checkbox2_2":false,"ComboboxCanvas2":[{"Value":"Item 2"}],"ComboboxCanvas2_1":[{"Value":"Item 13"},{"Value":"Item 12"}],
"TextInputCanvas3":"^123456ssgfsdfg","TextInputCanvas3_1":"453234234","TextInputCanvas3_2":"dsfasdfwerwrew"}]
 
PARSE:
ClearCollect(
    FormInputsCollection;
    ForAll(
        Table(ParseJSON(varFormData));
        {
            ComboboxCanvas2_1: Table(Value.ComboboxCanvas2_1);
            ComboboxCanvas2:  Value.ComboboxCanvas2;
            TextInputCanvas3_2: Text(Value.TextInputCanvas3_2);
            TextInputCanvas3_1: Text(Value.TextInputCanvas3_1);
            TextInputCanvas3: Text(Value.TextInputCanvas3);
            Checkbox2_2: Value.Checkbox2_2;
            Checkbox2_1: Value.Checkbox2_1;
            Checkbox2: Value.Checkbox2
        }
    )
)
 
as you can see for Comboboxes i tried just Value. and Table(Value.) non with success - but Table is almost there..can anyone tell me how i get the Combobox running?
 
Here a screenshot - where you an see what happens in ComboboxCanvas2_1:
 
As maybe some one will also want to do something like that and comes to this post... to access data:
TextInput - into Value:  First(FormInputsCollection).TextInputCanvas3
CheckBox - into Default: First(FormInputsCollection).Checkbox2
 
 
would appreciate your help with the combobox.
 
best regards
 
  • TSte Profile Picture
    175 on 24 Oct 2024 at 06:40:51
    Filling a Formular Screen with JSON Data
    Thanks you Nandit,
     
    this worked but for the Combobox, it was enough to just use :
    First(FormInputsCollection).Combobox2
     
    I have adapted my codes, cause i think i had problems that the variable name was exactly the same as input control..
     
    i now struggle the same way with a gallery, and fields in there.
    Just tried a approach similar to yours with, just with re specifying the 3 text fields, but without sucess..
     
    you also have a hint for that?
     
    here is my updated JSON code:
    Set(
        varFormData;
        JSON(
            [
                {
                    Combobox2: ComboboxCanvas2_1.SelectedItems;
                    Combobox1: ComboboxCanvas2.SelectedItems;
                    TextInput3: TextInputCanvas3_2.Value;
                    TextInput2: TextInputCanvas3_1.Value;
                    TextInput1: TextInputCanvas3.Value;
                    Check3: Checkbox2_2.Value;
                    Check2: Checkbox2_1.Value;
                    Check1: Checkbox2.Value;
                    Gallery3Data: ForAll(
                        Gallery3.AllItems;
                        If(
                            !IsBlank(text1_gallery.Value) && !IsBlank(text2_gallery.Value) && !IsBlank(text3_gallery.Value);
                            {
                                Text1_Gallery: Text(text1_gallery.Value);
                                Text2_Gallery: Text(text2_gallery.Value);
                                Text3_Gallery: Text(text3_gallery.Value)
                            }
                        )
                    )
                }
            ];
            JSONFormat.Compact
        )
    );;
     
    resulting into:
    [{"Check1":true,"Check2":true,"Check3":false,"Combobox1":[{"Value":"Item 2"}],"Combobox2":[{"Value":"Item 11"},{"Value":"Item 12"}],
    "Gallery3Data":[{"Text1_Gallery":"test","Text2_Gallery":"1234","Text3_Gallery":"test"},
    {"Text1_Gallery":"1234","Text2_Gallery":"5678","Text3_Gallery":"9101"},null],
    "TextInput1":"test1234","TextInput2":"test321","TextInput3":"asdf4321test"}]
     
     
    would be cool if you can help me also with that!
    thanks in advance, 
    Thomas
  • Suggested answer
    Nandit Profile Picture
    1,563 Super User 2025 Season 1 on 23 Oct 2024 at 16:23:20
    Filling a Formular Screen with JSON Data
     
    Phew, took me a minute but here's what you need to use in your Combobox DefaultSelectedItems:
    ForAll(
        Table(ParseJSON(varFormData).ComboboxCanvas2_1),
        Text(Value.Value)
    )
    Here's your updated code should look something like this:
    ClearCollect(
        FormInputsCollection;
        ForAll(
            Table(ParseJSON(varFormData));
            {
                ComboboxCanvas2_1: ForAll(Table(Value.ComboboxCanvas2_1), Text(Value.Value));
                ComboboxCanvas2:  Value.ComboboxCanvas2;
                TextInputCanvas3_2: Text(Value.TextInputCanvas3_2);
                TextInputCanvas3_1: Text(Value.TextInputCanvas3_1);
                TextInputCanvas3: Text(Value.TextInputCanvas3);
                Checkbox2_2: Value.Checkbox2_2;
                Checkbox2_1: Value.Checkbox2_1;
                Checkbox2: Value.Checkbox2
            }
        )
    )


    Hope this helps. 
     
    Kind regards,
    Nandit
     
    If this answers your query, please mark this response as the answer.
    If its helpful, please leave a like. Thanks!
     
     

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 106 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 73

#3
stampcoin Profile Picture

stampcoin 52

Overall leaderboard
Loading started