cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rlmckean
Helper IV
Helper IV

Dynamic change of properties of object in gallery not working

Hi

I wanted to add a dropdown in a gallery that would by default have Visible: false.

The property would be changed to Visible: True in the Onselect property of an icon or button. However I could not get this to work. I  tested other properties of the dropdown   and also a label and I could not get  any property of an object to change dynamically in the gallery control - 

Any suggestions why ??

 

Cheers

 

Richard

1 ACCEPTED SOLUTION

Accepted Solutions
mr-dang
Community Champion
Community Champion

I'm glad you were able to figure it out from the one word 🙂

 

Here's a trick I learned early on that helped me out a lot: you can use the ! operator in place of Not(). So if you want to toggle a context variable from true to false or false to true. I think this might be useful to you should you want your dropdown to reveal again.

 

UpdateContext({variable: !variable});

 

You could also use the same principle twice so that a variable goes from false to true, then true to false again. It's useful for resetting properties:

 

UpdateContext({variable: !variable});
UpdateContext({variable: !variable})

It is similar to:

 

UpdateContext({variable: true});
UpdateContext({variable: false})

 

Microsoft Employee
@8bitclassroom

View solution in original post

4 REPLIES 4
mr-dang
Community Champion
Community Champion

Hi,

Can you share the formula you are using in your icon/button?

Microsoft Employee
@8bitclassroom

Hi Mr-Dang

Many thanks for the reply - It was a senior moment (again!) and I only had to read the word Formula and I remembered you could not set properties dynamically in PowerApps ( unlike other applications I have been used to !) , but only by using Context Variables.

It would be good if an error had been raised when I put the formula in the Onselect property of the button   as 

Dropdown1.Visible = False

which is indeed invalid - instead of

updatecontext({editdropdown: false})

where editdropdown is my contextvariable and the Visible property of the dropdown is set to <editdropdown>. Strange how one can set back into a previous style even though the new requirements have already been used !!

 I am sure many newcomers to PowerApps may intially stumble at this hurdle as I did, as the requirement for declaring a context variable although documented, is kind of hidden in tutorial articles so you have to go a long read to find it !!

Thanks again

 

Richard

 

mr-dang
Community Champion
Community Champion

I'm glad you were able to figure it out from the one word 🙂

 

Here's a trick I learned early on that helped me out a lot: you can use the ! operator in place of Not(). So if you want to toggle a context variable from true to false or false to true. I think this might be useful to you should you want your dropdown to reveal again.

 

UpdateContext({variable: !variable});

 

You could also use the same principle twice so that a variable goes from false to true, then true to false again. It's useful for resetting properties:

 

UpdateContext({variable: !variable});
UpdateContext({variable: !variable})

It is similar to:

 

UpdateContext({variable: true});
UpdateContext({variable: false})

 

Microsoft Employee
@8bitclassroom

View solution in original post

Thanks for that - All good !!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,277)