web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / PowerApps does not cor...
Power Apps
Answered

PowerApps does not correctly handle Navigate() context records on screens navigated to by variable name.

(0) ShareShare
ReportReport
Posted on by

Hello! I'm currently writing an application and have encountered an inconsistency in how PowerApps handles local variables when passed using the Navigate() command. When navigating to a screen whose name is specified using a context variable from the previous screen, the records are not created properly. It's a bit difficult to explain, so let me use an example:

 

Example:

An app has three screens, "One", "Two", and "Three". On each screen, there is a button containing the below-listed OnSelect code.

 

Screen One: Navigate(Two, None, {forward: Three, back: One})

Navigate to screen two using no transition, passing the records "forward" and "back".

Result on button press: PowerApps navigates correctly to screen Two. Variables "forward" and "back" are set up properly.

Screen Two: Navigate(forward, None, {forward: Blank(), back: back})

Navigate to the screen specified in the variable "forward" (Three) using no transition, passing the records "forward" and "back".

Result on button press: PowerApps navigates correctly to screen Three. Variables "forward" and "back" are NOT set up properly on the next screen and cannot be read.

 

Screen Three: Navigate(back, None)
Navigate to the previous screen using no transition.

Result on button press: PowerApps fails to navigate, as the "back" variable was not set up properly on the previous screen.

 

Further experimentation leads me to believe this problem is exclusive to Navigate() calls where the page destination is a variable name specified in a context record; navigating to pages defined with an on-page UpdateContext() call function as intended.

 

If you're wondering what my use case for this weird page navigation structure is, I have a screen whose functionality is very simple: given a list of objects, ask the user which object in that list they'd like, then proceed to another page, passing the single item along. On the final page, there is a back button that skips the list-selector page by carrying the origin page's name in continually-passed context records.

 

Any help or potential workarounds would be appreciated. Thanks!

Categories:
I have the same question (0)
  • Verified answer
    iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    This is because you are trying to set a context variable to a different type - it doesn't show it explicitly because of the way you are passing them between screens. When you try set it to Blank(), you would normally get an incompatible type error as Screens and Blank() aren't the same type. The type mismatch then breaks your navigate as it can't navigate to 'error'.

     

    As a workaround, I would set and update a global variable instead of passing a context variable repeatedly. I don't think context variables are meant to be passed on repeatedly in this way, that's kinda the point of global variables.

     

    Screen1 Forward button

    Set(ForwardScreen, Two); Set(BackScreen, One);
    Navigate(ForwardScreen, ScreenTransition.None)

    Screen1 Back button

    Set(ForwardScreen, Two); Set(BackScreen, One);
    Navigate(BackScreen, ScreenTransition.None)

     Screen2 Forward Button

    Set(ForwardScreen, Three); Set(BackScreen, One);
    Navigate(ForwardScreen, ScreenTransition.None)

    Screen2 Back button

    Set(ForwardScreen, Three); Set(BackScreen, One);
    Navigate(BackScreen, ScreenTransition.None)

     

    Screen3 Forward button

    Set(ForwardScreen, Three); Set(BackScreen, Two);
    Navigate(ForwardScreen, ScreenTransition.None)

    Screen3 Back Button

    Set(ForwardScreen, Three); Set(BackScreen, Two);
    Navigate(BackScreen, ScreenTransition.None)

     

     

    ScreenNav.gif

     

    I have tested this and it navigates between then without issue.

    (attached proof of concept app for you to open and test)

     

    Cheers,

    Sancho

  • Neha94 Profile Picture
    19 on at

    Hello Sancho, I have been trying to replicate your solution for one of my projects, but I keep getting this error, any idea what I might have been doing wrong here?

     

    Neha94_0-1679655322358.png

    I need a dynamic value for the screen name and that should come from the QR I am scanning.

     

    Thank you in advance!

  • Neha94 Profile Picture
    19 on at

    This is the snap of what I tried 

    Neha94_0-1679659912246.png

     

  • iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    Ok, yeah so that's not going to work as we can't navigate to a text value, the Navigate function takes a Screen object as an input, so you'd have to have a condition in the navigate if you're using scan.

     

    Also, how are you getting the name of the screen from the scan? This will likely be a number you are scanning, so you'd need to do something like this:

    Set(Scan, BarcodeScanner1.Value)

    If(Scan = "74819269182", Navigate(Screen2),
     Scan = "68161861181", Navigate(Screen3)
     //etc etc etc
     // you will need to change those values to whatever your barcodes represent
    )

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard