cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Cybersurfer411
Level: Powered On

Using Checkboxes in Gallery recursively

Hello all!

 

I have a list of patient details in one main table (Patients gallery) that includes a few flags that point to another images table (Icon Gallery) in SQL Server datasource. I am trying to use checkboxes in my details page to select/unselect pictures for a given patient so only selected pics show up for a given patient. Each of these pictures is a flag option. I am able to write a seperate If statement to update each of the flags in the database but I am unable to use recursion to shorten the patch statement. Any help is appreciated! Thank you! 

---On Update button
If(
    Checkbox2.Value = true && Icon_Gallery_2.Selected.Icon_Name = "ISO_Flag",
    Patch(
        '[dbo].[Patients_2018]',
        Patients_Gallery.Selected,
        {ISO_Flag: 1}
    ),
    Patch(
        '[dbo].[Patients_2018]',
        Patients_Gallery.Selected,
        {ISO_Flag: "No"}
    )
);
If(
    Checkbox2.Value = true && Icon_Gallery_2.Selected.Icon_Name = "Heart_Flag",
    Patch(
        '[dbo].[Patients_2018]',
        Patients_Gallery.Selected,
        {Heart_Flag: 3}
    ),
    Patch(
        '[dbo].[Patients_2018]',
        Patients_Gallery.Selected,
        {ISO_Flag: "No"}
    )
);
SubmitForm(Edit_Form);
Navigate(
    Whiteboard_Display,
    ScreenTransition.Fade
)

P_App_2.JPGDatasource -SQL/2 tables

P_App_2_v2.JPG

3 REPLIES 3
Cybersurfer411
Level: Powered On

Using conditional recursive statement over checkboxes in image gallery

 

Hello all!

 

I have been breaking my head on how to get this functionality working. here is a description of the issue:

I have a list of patient details in one main table (Patients gallery) that includes a few flags that point to another images table (Icon Gallery) in SQL Server datasource. I am trying to use checkboxes in my details page to select/unselect pictures for a given patient so only selected pics show up for a given patient. Each of these pictures is a flag option. I am able to write an If statement to update each of the flags in the database but I am unable to use recursion to shorten the patch statement. Any help is appreciated! Thank you! 

 

---On "Submit button"
If(
    Checkbox2.Value = true && Icon_Gallery_2.Selected.Icon_Name = "ISO_Flag",
    Patch(
        '[dbo].[Patients_2018]',
        Patients_Gallery.Selected,
        {ISO_Flag: 1}
    ),
    Patch(
        '[dbo].[Patients_2018]',
        Patients_Gallery.Selected,
        {ISO_Flag: "No"}
    )
);
If(
    Checkbox2.Value = true && Icon_Gallery_2.Selected.Icon_Name = "Heart_Flag",
    Patch(
        '[dbo].[Patients_2018]',
        Patients_Gallery.Selected,
        {Heart_Flag: 3}
    ),
    Patch(
        '[dbo].[Patients_2018]',
        Patients_Gallery.Selected,
        {ISO_Flag: "No"}
    )
);
SubmitForm(Edit_Form);
Navigate(
    Whiteboard_Display,
    ScreenTransition.Fade
)

 P_App_2_v2.JPGP_App_2.JPGDatasource -SQL/2 tables

Community Support Team
Community Support Team

Re: Using Checkboxes in Gallery recursively

Hi @Cybersurfer411,

 

 

Could you please explain a bit for how the images and the checkboxes work here?

Just from the formula you posted, it seems the CheckBox is added manually for each of the images.

 

If the checkBox is added manually, then we could take use of the OnCheck and the OnUnCheck property to add/delete the record.

For example:

for the first CheckBox OnCheck property:

 

Collect(DataUse,Table({DefaultRecord: Patients_Gallery.Selected,Value:1}))

OnUnCheck property:

 

 

Remove(DataUse,{DefaultRecord: Patients_Gallery.Selected,Value:1})

 

 

For the other Checkbox, just update the Value part with the corresponding value.

Then under the Update button, switch the formula as below:

 

Forall(Datause, 
      patch('[dbo].[Patients_2018]', DefaultRecord, {ISO_Flag:Value})
);

SubmitForm(Edit_Form);
Navigate(
    Whiteboard_Display,
    ScreenTransition.Fade
)

 

See if that will work.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cybersurfer411
Level: Powered On

Re: Using Checkboxes in Gallery recursively


@v-micsh-msft wrote:

Hi @Cybersurfer411,

 

 

Could you please explain a bit for how the images and the checkboxes work here?

Just from the formula you posted, it seems the CheckBox is added manually for each of the images.

 

If the checkBox is added manually, then we could take use of the OnCheck and the OnUnCheck property to add/delete the record.

For example:

for the first CheckBox OnCheck property:

 

Collect(DataUse,Table({DefaultRecord: Patients_Gallery.Selected,Value:1}))

OnUnCheck property:

 

 

Remove(DataUse,{DefaultRecord: Patients_Gallery.Selected,Value:1})

 

 

For the other Checkbox, just update the Value part with the corresponding value.

Then under the Update button, switch the formula as below:

 

Forall(Datause, 
      patch('[dbo].[Patients_2018]', DefaultRecord, {ISO_Flag:Value})
);

SubmitForm(Edit_Form);
Navigate(
    Whiteboard_Display,
    ScreenTransition.Fade
)

 

See if that will work.

 

Regards,

Michael


Hi Michael,

I appreciate the response and my apologies for getting back late.

 

I was able to make progress on my App and got it working and do what I need it to do but I know it can be mor efficient. Here is the problem:

 

For every patient, there is some information (dropdowns/text fields) and a few icons are selected indicating their status (pictures to be selected using checkboxes). That forms one record.

 

To achieve this functionality, I create one Gallery for the Patients info (patient table) and one Icon Gallery (pictures table) for corresponding Icons. Patient gallery contains informatio and "Flags" of selected icons which I am displaying in Icon Gallery. I hope I am making sense. In a way, I am "joining" these 2 galleries (Icon gallery embedded  within patient gallery) so I can use the "icons" table only once and add images seperately. Each pictrue (icon) has a unique number that I am using as a "Flag" in my Patients table.

 

This is supposed to be a "Whiteboard" that will be always on - on a display. So i included timers for auto refresh of the screen and our SA worked to create a script so the browser never times out. 

 

I have a separate Patch command to update selected "Icon Flags" to the "Patient" Table.

 

So, IT is working as Expected.

 

Attached is the code and tables used. The question is:

1. Do we need to use both Refresh datasource and ClearCollect to keep the data updated or can we use just clear collect (i.e. does clear collect also refresh the DS?) so load times can be quicker because of so many pics (about 100 pics and each less than 5KB)

2. How can i use Forall or some other kind of iteration instead of a separate Patch command to update my patients table when a "Icon" is selected?

 3. I am frequently getting "Datasouce Not available" (though not always - intermittent behaviour) when I try to click on the "next arrow" to edit the selected item from "Patient" gallery although I wait for the page to load completely. I took the advise of someone else on this form to duplicate the screen but still takes a lot of time to move to the next page/error out. any remedies?

 

Thank you much in advance for your help!

 Final_Main_Screen.pngIcons_Gallery.pngONCHECK.pngOnStart_Screen.pngOnUNcheck.pngpatient_Icon_Select_Screen.pngPatient_Update_Scr_1.pngScreenshot from 2018-09-25 21_31_53.png

Main_Screen_Galleries.pngMainScreen_Galleries.png

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,599)