cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Kudo Collector
Kudo Collector

Navigate to a screen by it's name

Let's say I have a dropdown control in my PowerApps application named Nav with the next items:

 

[
    "1. Calculator", 
    "2. Counter", 
    "3. API", 
    "4. Collections", 
    "5. Dropdown", 
    "6. Acceleration", 
    "7. Camera"
]

 And I want to navigate to a screen by it's name. Something like:

Navigate(Nav.Selected.Value, ScreenTransition.Cover)

Is it possible to do somehow? Or is there a function that returns a control by it's name?

Navigate(GetControl(Nav.Selected.Value), ScreenTransition.Cover)

Because now I have to use If function to navigate in the app like this:

Navigate(If(
    "1" in Nav.Selected.Value, Screen1, 
    "2" in Nav.Selected.Value, Screen2, 
    "3" in Nav.Selected.Value, Screen3, 
    "4" in Nav.Selected.Value, Screen4, 
    "5" in Nav.Selected.Value, Screen5, 
    "6" in Nav.Selected.Value, Screen6, 
    "7" in Nav.Selected.Value, Screen7), 
ScreenTransition.Cover)

which does not look very nice. Is there more elegant solution? 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Power Apps
Power Apps

Re: Navigate to a screen by it's name

You cannot (currently) get a screen (or other controls) by its name - feel free to create a new suggestion in the Ideas board for that.

 

But for your specific scenario, you have a better alternative. Although you cannot get a control by its name, you can set a control as a property in the items collection for your dropdown, as shown below:

Table(
  { Text: "1. Calculator", Screen: Screen1 },
  { Text: "2. Counter", Screen: Screen2 },
  { Text: "3. API", Screen: Screen3 },
  { Text: "4. Collections", Screen: Screen4 },
  { Text: "5. Dropdown", Screen: Screen5 },
  { Text: "6. Acceleration", Screen: Screen6 },
  { Text: "7. Camera", Screen: Screen7 })

And in the action where you want to navigate (OnChange) you can call the navigate function with the value of the selected item in the dropdown:

Navigate(Dropdown1.Selected.Screen, ScreenTransition.Fade)

One of the advantages of this approach is that the definitions are in the same location - there's smaller risk for you to change the text of the dropdown and forget to change the formula elsewhere.

View solution in original post

Highlighted
Power Apps
Power Apps

Re: Navigate to a screen by it's name

PowerApps will try to make an educated guess the column to use to display in the dropdown. If your object has one column of type string, and one column of type <Screen> (or control), the option is fairly easy - pick the former.

 

There are situations where it will choose incorrectly, though. For example, imagine that this is your data source in the Items property of the dropdown:

Table(
  { Text: "1. Calculator", Screen: Screen1, AnotherText: "Calculator" },
  { Text: "2. Counter", Screen: Screen2, AnotherText: "Counter" },
  { Text: "3. API", Screen: Screen3, AnotherText: "API" },
  { Text: "4. Collections", Screen: Screen4, AnotherText: "Collections" },
  { Text: "5. Dropdown", Screen: Screen5, AnotherText: "Dropdown" },
  { Text: "6. Acceleration", Screen: Screen6, AnotherText: "Acceleration" },
  { Text: "7. Camera", Screen: Screen7, AnotherText: "Camera" })

PowerApps will choose one of them, but what you really wanted was the other one. So you can select the Dropdown, then select the View option in the Ribbon, then Advanced. You will see all the properties of the control, and under the Items property you will see a Value "subproperty", which you can use to select which of the fields to use.

Dropdown.PNG

View solution in original post

6 REPLIES 6
Highlighted
Power Apps
Power Apps

Re: Navigate to a screen by it's name

You cannot (currently) get a screen (or other controls) by its name - feel free to create a new suggestion in the Ideas board for that.

 

But for your specific scenario, you have a better alternative. Although you cannot get a control by its name, you can set a control as a property in the items collection for your dropdown, as shown below:

Table(
  { Text: "1. Calculator", Screen: Screen1 },
  { Text: "2. Counter", Screen: Screen2 },
  { Text: "3. API", Screen: Screen3 },
  { Text: "4. Collections", Screen: Screen4 },
  { Text: "5. Dropdown", Screen: Screen5 },
  { Text: "6. Acceleration", Screen: Screen6 },
  { Text: "7. Camera", Screen: Screen7 })

And in the action where you want to navigate (OnChange) you can call the navigate function with the value of the selected item in the dropdown:

Navigate(Dropdown1.Selected.Screen, ScreenTransition.Fade)

One of the advantages of this approach is that the definitions are in the same location - there's smaller risk for you to change the text of the dropdown and forget to change the formula elsewhere.

View solution in original post

Highlighted
Community Champion
Community Champion

Re: Navigate to a screen by it's name

Good! I am glad someone else is interested in this. I started an idea in the old TechNet forum for Indirect References, but it did not get traction. I don't think most users call it an indirect reference.

Microsoft Employee
@8bitclassroom
Highlighted
Kudo Collector
Kudo Collector

Re: Navigate to a screen by it's name

Yeah, thanks. This solution is much better. But how does PowerApps know whan to show as a text item in dropdown? We have complex object with two properties (columns) of type string and control named Text and Screen. Am I supposed to name property (column) exactly Text so it's value will be selected by default to display in the dropdown? Or is it just the first column that is picked as a displayable one? Because I tried different combinations of types and names and can not spot the pattern.

Highlighted
Power Apps
Power Apps

Re: Navigate to a screen by it's name

PowerApps will try to make an educated guess the column to use to display in the dropdown. If your object has one column of type string, and one column of type <Screen> (or control), the option is fairly easy - pick the former.

 

There are situations where it will choose incorrectly, though. For example, imagine that this is your data source in the Items property of the dropdown:

Table(
  { Text: "1. Calculator", Screen: Screen1, AnotherText: "Calculator" },
  { Text: "2. Counter", Screen: Screen2, AnotherText: "Counter" },
  { Text: "3. API", Screen: Screen3, AnotherText: "API" },
  { Text: "4. Collections", Screen: Screen4, AnotherText: "Collections" },
  { Text: "5. Dropdown", Screen: Screen5, AnotherText: "Dropdown" },
  { Text: "6. Acceleration", Screen: Screen6, AnotherText: "Acceleration" },
  { Text: "7. Camera", Screen: Screen7, AnotherText: "Camera" })

PowerApps will choose one of them, but what you really wanted was the other one. So you can select the Dropdown, then select the View option in the Ribbon, then Advanced. You will see all the properties of the control, and under the Items property you will see a Value "subproperty", which you can use to select which of the fields to use.

Dropdown.PNG

View solution in original post

Highlighted
Kudo Kingpin
Kudo Kingpin

Re: Navigate to a screen by it's name

This was some great guidance to help build some dynamic navigation in an app. I used a collection is generated OnVisible for a gallery and then based the gallery control off of the items in the collection. The tip about creating a column in a table that is of a screen type also works with a collection (this might be obvious, but just wanted to confirm that it works equally well).

 

+100 for this solution as it helped me provide some navigation within the app. I wish there was a better way to manage the list of navigation items rather than a collection that is generated on viewing the navigation screen.

Highlighted
Regular Visitor

Re: Navigate to a screen by it's name

can you please post your formula.

what i am try to do is:

Navigate(LookUp(CLTSvc,SvcRqst = ScheduleGal.Selected.SchFMSvcID1.Text,SvcCore),ScreenTransition.CoverRight)

 

I tested the look up and it has no issues resolving. when combined with Navigate it becomes an issue. I understand that first argument should be a control or screen.

 

Is there a way to have a button navigate based on a lookup value from a collection?

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (5,927)