top of page
Writer's pictureThe Tech Platform

Back and Navigate functions in Power Apps

Most apps contain multiple screens. Use the Back and Navigate function to change which screen is displayed. For example, set the OnSelect property of a button to a formula that includes a Navigate function if you want to show a different screen when a user selects that button. In that formula, you can specify a visual transition, such as Fade, to control how one screen changes to another.


Back and Navigate change only which screen is displayed. Screens that aren't currently displayed continue to operate behind the scenes. You can build formulas that refer to properties of controls on other screens. For example, a user can change the value of a slider on one screen, navigate to a different screen that uses that value in a formula, and determine how it affects what happens in the new screen. The user can then navigate back to the original screen and confirm that the slider has kept its value.


Context variables are also preserved when a user navigates between screens. You can use Navigate to set one or more context variables for the screen that the formula will display, which is the only way to set a context variable from outside the screen. You can use this approach to pass parameters to a screen. If you've used another programming tool, this approach is similar to passing parameters to procedures.

You can use either function only within a behavior formula.


Navigate

In the first argument, specify the name of the screen to display.

In the second argument, specify how the old screen changes to the new screen:


ScreenTransition.Cover

The new screen slides into view, moving right to left, to cover the current screen.









ScreenTransition.CoverRight

The new screen slides into view, moving left to right, to cover the current screen.








ScreenTransition.Fade

The current screen fades away to reveal the new screen.









ScreenTransition.None

(Default)The new screen quickly replaces the current screen.









ScreenTransition.UnCover

The current screen slides out of view, moving right to left, to uncover the new screen.








ScreenTransition.UnCoverRight

The current screen slides out of view, moving left to right, to uncover the new screen.








You can use Navigate to create or update context variables of the new screen. As an optional third argument, pass a record that contains the context-variable name as a column name and the new value for the context variable. This record is the same as the record that you use with the UpdateContext function.

Set the OnHidden property of the old screen, the OnVisible property of the new screen, or both to make additional changes during the transition. The App.ActiveScreen property will be updated to reflect the change.


Navigate normally returns true but will return false if an error is encountered.

Context variables for navigation are explained in the article navigate between screens.


Back

The Back function returns to the screen that was most recently displayed.


For each Navigate call, the app tracks the screen that appeared and the transition. You can use successive Back calls to return all the way to the screen that appeared when the user started the app.


When the Back function runs, the inverse transition is used by default. For example, if a screen appeared through the CoverRight transition, Back uses UnCover (which is to the left) to return. Fade and None are their own inverses. Pass an optional argument to Back to force a specific transition.


Back normally returns true but returns false if the user hasn't navigated to another screen since starting the app.


Syntax

Back( [ Transition ] )

  • Transition - Optional. The visual transition to use between the current screen and the previous screen. Refer to the list of valid values for this argument earlier in this article. By default, the transition through which a screen returns is the inverse of the transition through which it appeared.

Navigate( Screen [, Transition [, UpdateContextRecord ] ] )

  • Screen - Required. The screen to display.

  • Transition - Optional. The visual transition to use between the current screen and the next screen. See the list of valid values for this argument earlier in this article. The default value is None.

  • UpdateContextRecord - Optional. A record that contains the name of at least one column and a value for each column. This record updates the context variables of the new screen as if passed to the UpdateContext function.

Examples



Step-by-step

  1. Create a blank app.

  2. Add a second screen to it. The app contains two blank screens: Screen1 and Screen2.

  3. Set the Fill property of Screen2 to the value Gray.

  4. On Screen2, add a button, and set its OnSelect property to this formula: Navigate( Screen1, ScreenTransition.Cover )

  5. While holding down the Alt key, select the button. Screen1 appears with a white background through a transition that covers to the left.

  6. On Screen1, add a button, and set its OnSelect property to this formula: Back()

  7. While holding down the Alt key, select the button. The second screen appears with a gray background through a transition that uncovers to the right (the inverse of Cover).

  8. Select the button on each screen repeatedly to bounce back and forth.


Watch Talks Academy with Aroh Shukla on Power Apps - Session 2

The Tech Platform


Source: Microsoft

0 comments

Comments


bottom of page