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

Navigate Context Variable

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?Capture.PNG".

1 ACCEPTED SOLUTION

Accepted Solutions

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.

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

View solution in original post

10 REPLIES 10
Super User
Super User

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.

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training
Helper II
Helper II

I’ve tried OnSelect on a gallery and OnChange of a dropdown. Both give me the same error. I’ve tried the web client and Windows client with same results. I’ve done this dozens of times before so I don’t know if it’s some sort of a new bug or if I’m just having a senior moment.

ThisItem.Screen is what is confusing me. Try hardcoding Screen1 (or whatever your screen name is) and see if that works.

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

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.

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

View solution in original post

Thanks for the quick response, Shane.  That's a pain in the butt!  Smiley Frustrated


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 😞

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (62,249)