cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

How to check or uncheck a checkbox in a gallery without appending to a variable

All,

 

Can I am new to power apps and have been stuck on this. Can someone help please.

 

I have a gallery with 4 checkboxes in it.  I need to email those that are selected.

This is what I have but not sure hwo to fix it.

 

1) OnCheck I have 

Set(ItemsSelected, Concatenate(ItemsSelected, ThisItem.'Task Name'))

Q1) every time the form is submitted, it seems that ItemsSelected Variable grows. I tried to use reset and it did not work.

Q2) if user decideds to uncheck a checkox, how do I remove from from my variable?

 

Any pointer is greatly appreciated.

 

Thanks,

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Anonymous
Not applicable

Re: How to check or uncheck a checkbox in a gallery without appending to a variable

Thank you all for taking the time to respond to my question.

View solution in original post

7 REPLIES 7
KickingApps
Level 8

Re: How to check or uncheck a checkbox in a gallery without appending to a variable

Will you please send a screen shot of your gallery?

 

Have you considered a collection for the items that are checked within the gallery.  Upon Submit, you can clear the collection.  If you uncheck an item, you can easily remove it from the collection.

Anonymous
Not applicable

Re: How to check or uncheck a checkbox in a gallery without appending to a variable

Thanks for replying.  Yes, I tried to use collection, however my chackboxes are in a gallery and I I need a 
forAll and Filter to select only those checkboxes that are selected. No matter how I did it,  I could not get the correct syntax for 

ForAll (Filter(Collection name)) 

that is basically what the issues is. 

 

I definced a global variable and appended all those checkboxes that were selected , however If a user uncheck one, I can't drop it (not a good approach)

I tried to use a collection, and if 3 items are selected, only one of them shows up in the collection. 
how do you do ForAll and select only those that are checked so my the collection should get 3 rows in case 3 checkboxes are selected. I can't use item1, item2 ... since ony one checkbox name is available.

Thanks again

 

,Gal.jpg

gokello
Level 8

Re: How to check or uncheck a checkbox in a gallery without appending to a variable

As @KickingApps has mentioned, best is to use a collection.

I have an app that does something similar and this is my syntax for the "For All":

 

ForAll(Filter(galClientList.AllItems,chkSelectRecord.Value = true),Collect(colSelectedItems,{ID:Value(lblID.Text)}));

 

Where:

- galClientList is the name of the gallery

- chkSelectRecord is the name of the checkbox

- colSelectedItems is the name of the collection

 

I am holding the IDs in the collections

 

Super User
Super User

Re: How to check or uncheck a checkbox in a gallery without appending to a variable

Hello Gulf_Man,

You also add a label (you don't need the label but it a way to display the result)
Label1.Text= Concat(Gallery1.AllItems,If(Checkbox1.Value,'Task Name'))


Instead of Gallery1 and Checkbox1, you need to use the names of your Gallery and Checkbox

Anonymous
Not applicable

Re: How to check or uncheck a checkbox in a gallery without appending to a variable

Thanks for your instructions. I will give it a try and le you know in a couple of days.. Greatly appreciated.

Community Support Team
Community Support Team

Re: How to check or uncheck a checkbox in a gallery without appending to a variable

Hi @Anonymous ,

Based on the formula that you provided, I think the global variable could achieve your needs.

 

As an alternative solution, you could consider take a try to initialize a Collection to collect the Task Name when the corresponding CheckBox is checked.

I have made a test on my side, please take a try with the following workaround:

Set the OnCheck property of the Checkbox to following:

Collect(ItemsSelected, ThisItem.'Task Name')

Set the OnUncheck property of the Checkbox to following:

Remove(ItemsSelected, LookUp(ItemsSelected, Value = ThisItem.'Task Name'))

 

If you want to use ForAll function to collect those checkboxes that are selected, I have made a test on my side, please take a try with the following workaround:

ForAll(
         Filter(Gallery_M.AllItems, Checkbox1.Value = true),
         Collect(
                    ItemsSelected,
                    'Task Name'
         )
)

 

If you want to display the selected Task Name within a Label control, please set the Text property of the Label to following:

Concat(ItemsSelected, Value & "; ")

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Anonymous
Not applicable

Re: How to check or uncheck a checkbox in a gallery without appending to a variable

Thank you all for taking the time to respond to my question.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

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
Users online (5,760)