It seems I can't pass a variable via navigate any longer. No matter what the variable is, I get the same error: "Context variables cannot be used here. Context variable can only be bound to a single, specific screen". Anyone else see this?".
Solved! Go to Solution.
I have never gotten a function to accept data like that or via a variable. It annoys me a lot. 🙂
What you would have to do is make your Onselect an If.
If( ThisItem.Name = "Salary Change", Navigate(PANSalaryChangeScreen,Cover),
ThisItem.Name = "Transfer", Navigate(TransferPanScreen,Cover)
)
Something like that should work.
Maybe we need more details? Where are you putting this property and on what type of control?
I just created a button and for OnSelect I did Navigate(Screen2,ScreenTransition.Cover,{BestPowerAppsConsultingCompany: "PowerApps911"}) and it works.
ThisItem.Screen is what is confusing me. Try hardcoding Screen1 (or whatever your screen name is) and see if that works.
The gallery is filled with a collection. That is where the thisitem.screen comes from. Here is the collection:
ClearCollect(PanTypes,
{Name: "Salary Change", Screen: PANSalaryChangeScreen},
{Name: "Transfer", Screen: TransferPanScreen})
But, you know what, that was it. I hardcoded a screen and it worked fine...I know I've set up a collection like this before and it worked fine. Is there a syntax issue?
I have never gotten a function to accept data like that or via a variable. It annoys me a lot. 🙂
What you would have to do is make your Onselect an If.
If( ThisItem.Name = "Salary Change", Navigate(PANSalaryChangeScreen,Cover),
ThisItem.Name = "Transfer", Navigate(TransferPanScreen,Cover)
)
Something like that should work.
Thanks for the quick response, Shane. That's a pain in the butt!
I hope they offer something like that for us soon.
Or a switch for little easier on the eye.
Switch( ThisItem.Random,
"Screen1",Navigate(Screen1, Fade),
"Screen2",Navigate(Screen2, Fade),
"Screen3",Navigate(Screen3, Fade),
"Screen4",Navigate(Screen4, Fade)
)
Really annoying we can't just put the variable straight into the Navigate though. Another use case, I have a Middle-Man screen hop where control property variables (colour, size ect) are defined on splash. Some of these are taken from a "User Settings" table. When user changes settings, it hops back to splash to re-do all the property variables then hops back to the screen the user was last on.
I had hoped I could just define a global variable containing the current screen's name on the OnClick of the Settings button (eg Set(gloSettingsReturn, Parent.Name)), then simply have Navigate(gloSettingsReturn) on my splash page, but nooo. Now I need a big fat Switch.
What is strange is that it was working previously. I've got an app that I built about 2 years ago. Some formula involved variables to define the navigate screen and it was working perfectly fine. I updated the app today, and now I have this error 😞
Check out new user group experience and if you are a leader please create your group
See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.
User | Count |
---|---|
256 | |
254 | |
81 | |
41 | |
30 |
User | Count |
---|---|
321 | |
263 | |
122 | |
65 | |
49 |