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

Only the Last Items in Gallery set variable right?

I have a Gallery like that:

Screen Shot 2019-11-30 at 12.50.56 PM.png

 

DataSource: colServices (a Collection, has Section Property: 1,2,3..., Request: true, false)

Toggle:

Default: ThisItem.Request

OnChange: Patch(colServices, ThisItem, Request = Toggle.Value)

OnCheck: UpdateContext({varEdit: ThisItem.Section})
OnUncheck: UpdateContext({varEdit: 0})

This variable will set the display mode of the component in the gallery.

Component.DisplayMode: If(varEdit = ThisItem.Section, Edit, View)

 

But Only the Last Item (Sectionm = 8 ) in Gallery has the right Effect (Please see the picture above)

The other items will set the varEdit=ThisItem.Section in a moment (0.1s), then change it to 0 after. (See the picture below)

Screen Shot 2019-11-30 at 12.51.58 PM.png

 

 

Please explain and help me!

 

1 REPLY 1
Highlighted
Super User
Super User

Re: Only the Last Items in Gallery set variable right?

Hi,

 

You're only setting one variable to that value, so the last action to effect it will be the only one to show correctly 😺

 

So what's happening is that your gallery is going through and each time the toggle changes value its doing:

UpdateContext({varEdit: ThisItem.Section}) which is setting it to like 1,2,3,4,etc, and then 8, (the last one that is OnChecked)

 

and then its checking

If(varEdit = ThisItem.Section, Edit, View)

for each of your items, but varEdit is 8 now, so none of the others will be in edit mode as 8 = 8 is the only true value

 

So what I would do instead is set your component DisplayMode as:

If(Toggle1.Value=true, Edit, View)

- this will be evaluated individually in gallery rows so should Edit the ones that are checked only.

 

 

Could you give that a try and let me know whether it worked for you?

 

Thanks,

Sancho




Don't forget to 'Mark as Solution' if a post answered your question and always 'Thumbs Up' the posts you like or helped you!

Helpful resources

Announcements
thirdimage

Power Automate 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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

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