cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

Gallery Checkboxes and Toggles Uncheck Automatically

Hi Everyone,

 

I'm building a simple app where I have a list of individuals that I need to be able to check / select or unselect from the gallery screen (screenshot in attachments). I'm using these Patch() functions to update a Sharepoint list : 

 

For OnCheck

Patch('Associate Consultants', LookUp('Associate Consultants', ID=BrowseGallery1.Selected.ID), {Selected: "Yes"})

 

For On UnCheck

Patch('Associate Consultants', LookUp('Associate Consultants', ID=BrowseGallery1.Selected.ID), {Selected: "No"})

 

Note: Selected is a column name in my Sharepoint list (I'm not sure if it's a reserved word in PowerApps). This is for use in a flow at a later stage where Sharepoint doesn't like True / False columns.

 

What happens is that all works really well when I add the Patch for OnCheck, but as soon as I add the Patch for On Uncheck, the toggles (checkboxes do the same thing) behave strangely. If I toggle one gallery item it may (or may not) uncheck itself. If I toggle two they will both uncheck. If I toggle 3 they will stay toggled, until I uncheck one and they will ALL uncheck.

 

I'm certain I've missed something very basic here but all my research (read: Googling) has pointed me to solutions where checking multiple boxes / toggles is the preferred behaviour, so I can't see why this is happening when I don't need it.

 

Any help would be greatly appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Champion
Community Champion

Re: Gallery Checkboxes and Toggles Uncheck Automatically

Hi @Serviced2000 ,

I posted this one a short time ago - the second bit is similar to what you need - using this syntax, yours I believe would be something like

ForAll(
   RenameColumns(
      YourGalleryName.AllItems,
      ),
      "ID",
      "IDRef"
   ),
   UpdateIf(
      'SP list',
      ID = IDRef,
      {
         Consultant_Selected:
         If(
            Toggle4.Value,
            "Yes",
            "No"
         )
      }
   )
)

 

Please click Accept as solution 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 giving it Thumbs Up.

 

View solution in original post

20 REPLIES 20
Highlighted
Community Champion
Community Champion

Re: Gallery Checkboxes and Toggles Uncheck Automatically

Hi @Serviced2000 ,

Firstly, you are correct in that Selected is a reserved word and you should rename this control as soon as possible.

If this does not fix the issue, you can look at a Default value which you can set with a Variable to the value of the control on the OnChange but on the condition that ThisItem.IsSelected is true.

Have a go at this first - happy to help further.

 

Please click Accept as solution 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 giving it Thumbs Up.

Highlighted
Regular Visitor

Re: Gallery Checkboxes and Toggles Uncheck Automatically

Thanks @WarrenBelz - I changed the column name to Consultant_Selected but that hasn't changed the behaviour. When it comes to changing the default with a variable where would I put the ThisItem.IsSelected bit - in the OnCheck / On Uncheck Actions? 

 

Apologies - should probably have mentioned I'm a complete novice in this space...

Highlighted
Community Champion
Community Champion

Re: Gallery Checkboxes and Toggles Uncheck Automatically

Hi @Serviced2000 ,

On the Default.

I just did some basic testing, not necessarily mirroring yours, but I did the following on a checkbox in a gallery.

On both the OnCheck and OnUncheck (add your other code as well) and replace control  name with yours.

UpdateContext({vCheck:YourCheckboxName.Value})

 The Default of the Checkbox

If(ThisItem.IsSelected,vCheck)

 

Please click Accept as solution 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 giving it Thumbs Up.

Highlighted
Regular Visitor

Re: Gallery Checkboxes and Toggles Uncheck Automatically

Sorry @WarrenBelz,

 

Still no - now, when I click the second toggle it goes on and then off and the first toggle switches to off as well. Apologies - I've probably missed something really basic here. I've added a snip of the toggle properties which will hopefully show what I've done. If this looks correct I might kill this app altogether and start afresh in case I've messed anything up in the earlier stages...

Highlighted
Community Champion
Community Champion

Re: Gallery Checkboxes and Toggles Uncheck Automatically

Thanks @Serviced2000 ,

Did you change the Default of Toggle4 to

If(ThisItem.IsSelected,vCheck)

 

Highlighted
Regular Visitor

Re: Gallery Checkboxes and Toggles Uncheck Automatically

Thanks @WarrenBelz ,

 

I'm pretty sure this is in the right place...

 

 

Gallery3.PNG

Highlighted
Community Champion
Community Champion

Re: Gallery Checkboxes and Toggles Uncheck Automatically

Hi @Serviced2000 ,

UPDATE - 

A bit more testing and I am getting the same strange behavior.

The following works a bit better - but clunky and does a few other strange things.

Default

If(ThisItem.IsSelected,vCheck)

OnCheck

Select(Parent);
Patch(
   'Associate Consultants', 
   LookUp(
      'Associate Consultants', 
      ID=BrowseGallery1.Selected.ID
   ), 
   {Selected: "Yes"}
;)
Refresh('Associate Consultants');
UpdateContext({vCheck:true})

OnUncheck

Select(Parent);
Patch(
   'Associate Consultants', 
   LookUp(
      'Associate Consultants', 
      ID=BrowseGallery1.Selected.ID
   ), 
   {Selected: "No"}
;)
Refresh('Associate Consultants');
UpdateContext({vCheck:false})

 

Please click Accept as solution 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 giving it Thumbs Up.

 

Highlighted
Regular Visitor

Re: Gallery Checkboxes and Toggles Uncheck Automatically

Awesome! At least I'm not being totally dumb! 🙂

 

I'll give this a try and come back to you...

Highlighted
Regular Visitor

Re: Gallery Checkboxes and Toggles Uncheck Automatically

Hi @WarrenBelz ,

 

Definitely some weird stuff going on there. Still not working quite as I'd hoped though. I would have thought this would be a pretty simple thing. Change toggle -> Update Data Source... The End. I can't see why it's changing back - even though we've change the default behaviour to cover any screen / page refreshing.

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,161)