cancel
Showing results for 
Search instead for 
Did you mean: 
audrieg

Conditional Navigation - Triggered by User Selection

Most of the time we are adding navigation via an icon in the top navigation, or a button push such as a "Next" prompt. In those cases, it is very easy to auto-build our navigation formulas by selecting the object which will be the trigger, and using the Action Menu to add navigation.

 

Tip: Did you notice that you can select the screen and the transition directly from the Navigation drop downs on the Action tab? When you do that PowerApps builds the navigation formula for you! Easy peezy!

 

screennavigation.PNG

 

A slightly different scenario:

On the other hand, there are times when we want to determine navigation based on user selection somewhere on the current screen. In the sample below, we built a ficticious sample app which returns feature statistics for our sprint. In addition, it allows the Program Managers to suggest new features (driven by customer EBC) by clicking on the small push pin on the lower right hand corner of the screen.

 

Screen1.PNG

 

Here's the catch: Each Product has a different set of field values required to suggest a feature....so a different form is needed based on the product selection (enablement often leads to diversity in intake systems - smiles). Therefore, we have a different request screen in the app for each product name.

 

Not to worry! This is an exceptionally easy thing to do in PowerApps. The way I choose to do it is by setting the OnSelect property for the push pin icon in this way:

 

Step 1: Select the Push Pin Icon

Step 2: Set the OnSelect property with a conditional format similar to this one (change the screen names and drop down names as needed):

 

If("A" in ddProductName.Selected.Value,Navigate(ScreenProductA, ScreenTransition.Fade),
If("B" in ddProductName.Selected.Value,Navigate(ScreenProductB, ScreenTransition.Fade),
Navigate(ScreenProductC, ScreenTransition.Fade)))

 

Translated the above formula really means:

If "A" is found in the selected Product Name then navigate to the screen named "ScreenProductA", or if "B" is found in the selected Product Name then navigate to the screen named "ScreenProductB", ELSE navigate to the screen named "ScreenProductC").

 

Any operator can be used (such as equals) instead:

If(ddProductName.Selected.Value="Product A",Navigate(ScreenProductA, ScreenTransition.Fade),
If(ddProductName.Selected.Value="Product B",Navigate(ScreenProductB, ScreenTransition.Fade),
Navigate(ScreenProductC, ScreenTransition.Fade)))

 

The If() function is a handy tool for many types of conditions including navigation. I've written it completely out here for the sake of readability, but you can abbreviate nested "If" statements as broken down in our formula reference here:

https://powerapps.microsoft.com/en-us/tutorials/function-if/

 

I hope this mini-blog helps you to enjoy, and to enhance your PowerApps today!

 

Audrie

Comments

Hi

 

Yes, abb. nested if is short and precise. I learnt from MS Staff and tutorial, too.

Thanks.

The Table() function is another strong one to try since it can reference Screens.

 

Set Gallery1.Items to:

 

 

Table(
{id: 1, navto: Screen1},
{id: 2, navto: Screen2},
{id: 3, navto: Screen3}
)

 

 

Add a Button or another object with OnSelect property and set it to:

 

 

Navigate(ThisItem.navto,Fade)

 

 

By using Table(), you won't need to set any conditions for the Button since the Screen is already determined in each record of the table.

 

This method is useful if you only have a few Screens you want to designate for navigation.

Anonymous

Hi, I have embedded several Power BI tiles (set up as individual "dashboard" screens), and I'd like to conditionally navigate to these screens based off of user selection from another screen.  The navigation should be based off a specific item selected from a Gallery.  The Gallery is connected to a OneDrive Excel sheet.  

 

I have a column in my OneDrive Excel sheet labeled 'Product Name' which is being referenced in my Gallery.  Depending on which 'Product Name' is selected, my app takes me to a Form page (called Details), which provides more details about the Product.  The details of the product are also in the Excel sheet, so the form text all refers back to Parent.Default.  It is from this Details form which I want to navigate to the appropriate Power BI sheet, via a button.  However, the navigation is condtional based on which product was selected from the Gallery.   How should I write my formula to navigate this?

 

Thanks.

This is cool and how about if I need to open form also in the new screen? I mean based on the dropdown value, navigtate to new screen and create a new record. My Scenario is like from Opportunity if user select 'Partner' in dropdown, Partner screen with new form should popup and if user select 'Distributor', Distributor screen with new form should popup. Is there any way of achieving this?