Reputation: 3
I hope to get help for this. I'm new to power apps and I'm trying to create a global variable with value as the selected item from my gallery. But it does not update whenever I choose another item. I made sure to hit on Run OnStart while testing but it still doesn't update the value.
I've tried refreshing the data source, but I think it has nothing to do with the global variable. I need an updated value of the global variable as the edit form on the next page is using that info.
Upvotes: 0
Views: 3111
Reputation: 87318
Do you need to use a variable? In any place in your app where you use Var_DiscoveryMeeting_Selected
you can use Gallery_DiscoveryMeeting.Selected
instead - and all properties that depend on that value will be recalculated whenever the selection of the gallery changes (Power Apps uses a primarily declarative language, where variables in many cases are not necessary).
If you really need to use a variable, then you can use the OnSelect property of the Gallery_DiscoveryMeeting itself, where you could have something like Set(Var_DiscoveryMeeting_Selected, ThisItem)
. But if you don't need it, I wouldn't suggest doing so. For example, if you add a control inside a gallery, and need to handle its OnSelect property, you'll need to remember to invoke the OnSelect of the gallery in addition to doing what the control needs to do.
Upvotes: 0