cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Super User
Super User

Re: Navigate Context Variable

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

8 REPLIES 8
Highlighted
Super User
Super User

Re: Navigate Context Variable

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
Highlighted
Helper II
Helper II

Re: Navigate Context Variable

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.
Highlighted
Super User
Super User

Re: Navigate Context Variable

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
Highlighted
Helper II
Helper II

Re: Navigate Context Variable

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})

Highlighted
Helper II
Helper II

Re: Navigate Context Variable

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?

Highlighted
Super User
Super User

Re: Navigate Context Variable

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

Highlighted
Helper II
Helper II

Re: Navigate Context Variable

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.

Highlighted
Helper II
Helper II

Re: Navigate Context Variable

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.

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (10,366)