cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
21DRick
Frequent Visitor

Patching gallery with toggle

Hi there,

 

This seems to be an issue that's popped up before but I haven't found a solution that I can apply to my case (it may be that one does not exist!)

 

So fairly simple setup in a collection called summarypackage:

UnitIdRequiredFg
10
21
30
41
51

 

Collection returning in a Gallery, with the UnitId in Column 1 and a Toggle in Column 2.

 

I set the OnCheck value to:

 

Patch(summarypackage,LookUp(summarypackage, UnitId = ThisItem.UnitId),{RequiredFg: 1}),

 

 

And the OnUnCheck value to:

 

Patch(summarypackage,LookUp(summarypackage, UnitId = ThisItem.UnitId),{RequiredFg: 0})

 

 

The issue that occurs is that while initially the Toggle will reflect the patch, it then refuses to toggle on, even though the patch is successful (see attached)

 

Seems the same issue was discussed here however I cannot get a solution to work.

 

Trying and If() statement on the OnChange didn't work, e.g. 

 

If(RequiredCheck.Value=true,Patch(summarypackage,LookUp(summarypackage, UnitId = ThisItem.UnitId),{RequiredFg: 1}),Patch(summarypackage,LookUp(summarypackage, UnitId = ThisItem.UnitId),{RequiredFg: 0}));

 

 

And setting a Default value to read from the Collection just created an infinite loop (I guess because Patch would apply, field would read that value had changed, so switch toggle, which would reapply the patch etc etc)

 

If anyone is able to help with a workaround to get the toggle to function correctly it'd help a lot!

 

I've managed to get a working version with a Radio Select but a Toggle would be preferable (if I can get it to work!)

 

Thanks in advance for any help you can give,

 

R

1 ACCEPTED SOLUTION

Accepted Solutions
21DRick
Frequent Visitor

Just in case anyone else comes across this issue.

 

There doesn't appear to be an actual fix for the toggle bug but you can make a button function like a toggle in a gallery:

 

Add Button, then in OnSelect property to update collection, add the following :

(This will check value in collection and apply opposite value when user clicks button)

 

If(LookUp('collectionname', Id = ThisItem.Id).RequiredFg = 1, Patch('colletionname',LookUp('collectionname', Id= ThisItem.Id),{RequiredFg: 0}),Patch('collectionname',LookUp('collectionname', Id= ThisItem.Id),{RequiredFg: 1}))

 

Then in the Fill value of the Button, check the Collection to see what value there is and apply color accordingly:

 

If(LookUp('collectionname', Id= ThisItem.UnitId).RequiredFg = 1, ColorValue("#FFFFFF"), ColorValue("#000000"))

 

 

This will function like a Toggle and appear to the user to have 'Clicked' and 'UnClicked' status, so behaviorally works like a toggle too!

 

Hope this helps someone 🙂

View solution in original post

1 REPLY 1
21DRick
Frequent Visitor

Just in case anyone else comes across this issue.

 

There doesn't appear to be an actual fix for the toggle bug but you can make a button function like a toggle in a gallery:

 

Add Button, then in OnSelect property to update collection, add the following :

(This will check value in collection and apply opposite value when user clicks button)

 

If(LookUp('collectionname', Id = ThisItem.Id).RequiredFg = 1, Patch('colletionname',LookUp('collectionname', Id= ThisItem.Id),{RequiredFg: 0}),Patch('collectionname',LookUp('collectionname', Id= ThisItem.Id),{RequiredFg: 1}))

 

Then in the Fill value of the Button, check the Collection to see what value there is and apply color accordingly:

 

If(LookUp('collectionname', Id= ThisItem.UnitId).RequiredFg = 1, ColorValue("#FFFFFF"), ColorValue("#000000"))

 

 

This will function like a Toggle and appear to the user to have 'Clicked' and 'UnClicked' status, so behaviorally works like a toggle too!

 

Hope this helps someone 🙂

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (3,305)