cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

How to expand a variable to a screen name for Navigate?

I can't figure out how to pass a text to the screen name argument of the Navigate function.

I can generate the text of the next screen name, and use it in a label, but I can't seem get navigate to accept anything other than manually entered text.

 

I've been unsuccessful with the following approaches (and variants that I've lost track off)...

 

Navigate(Screen & (scrNum+1),ScreenTransition.Fade))

Navigate(Screen & Text(scrNum+1),ScreenTransition.Fade)

Navigate(Text("Screen" & (scrNum+1)),ScreenTransition.Fade)

Navigate(Concatenate("Screen",Text(scrNum+1)), ScreenTransition.Fade)

 

I also tried simplifying the expansion by removing the arithmetic and iterating through the above

 

UpdateContext({nextScr:(scrNum+1)};

Navigate(Screen & nextScr),ScreenTransition.Fade)

 

Can anyone tell me what I'm doing wrong? 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: How to expand a variable to a screen name for Navigate?

Hi @CMetcalfe ,

 

The control cannot be called by its string name!

the Screen1 you entered in the formula bar is a control, but the "Screen1" is a string, they are different type.

Snipaste_2019-12-16_17-06-12.pngSnipaste_2019-12-16_17-07-54.png

Currently, the function to invoke controls as strings is not supported in PowerApps. If you want this feature, please submit an idea to PowerApps Idea forum.

Best regards,

Sik

View solution in original post

5 REPLIES 5
Highlighted
Super User
Super User

Re: How to expand a variable to a screen name for Navigate?

@CMetcalfe 

You cannot refer to a screen name indirectly in PowerApps as you are attempting to do.

It's not ideal but you can use SWITCH like this if your app is being developed over several screens.

 

Set(scrNum, scrNum + 1);
Switch(
    scrNum,
    1, Navigate(Screen1, Fade),
    2, Navigate(Screen2, Fade),
    3, Navigate(Screen3, Fade),
    4, Navigate(Screen4, Fade),
    5, Navigate(Screen5, Fade)
)

 

The other approach would be to put everything on a single screen and make the controls visible when the appropriate page number matches the variable scrNum.  It would involve putting code like this in the Visible property of each control.

scrNum=1 //if you want the control to show when on Page1

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Highlighted
Frequent Visitor

Re: How to expand a variable to a screen name for Navigate?

Hi @mdevaney - thank you for taking the time to respond, even if it wasn't the answer I was expecting!

 

 

Sigh:  So the Navigate function only accepts strings that originated from the keyboard?  How does it even tell? /s  😉

 

I'll just have to go through my project and manually edit all of the 'advance' icons.

Highlighted
Super User
Super User

Re: How to expand a variable to a screen name for Navigate?

@CMetcalfe 

Q: "Sigh:  So the Navigate function only accepts strings that originated from the keyboard?  How does it even tell?"

 

A:  References to screen names must always be static (as opposed to variable).  Right now that's just the way things are...

 

Have you ever encountered the INDIRECT function is Microsoft Excel?  To enact your solution that's essentially what would be needed to do it.  INDIRECT takes a string as an argument and evaluates to a cell reference.  In PowerApps we would need INDIRECT to evaluate to a control reference.

 

If you have a strong desire to see this functionality included in PowerApps you can always go create an Idea and encourage others to vote on it.

Link to MS Ideas

https://powerusers.microsoft.com/t5/Power-Apps-Community/ct-p/PowerApps1

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

Highlighted
Community Support
Community Support

Re: How to expand a variable to a screen name for Navigate?

Hi @CMetcalfe ,

 

The control cannot be called by its string name!

the Screen1 you entered in the formula bar is a control, but the "Screen1" is a string, they are different type.

Snipaste_2019-12-16_17-06-12.pngSnipaste_2019-12-16_17-07-54.png

Currently, the function to invoke controls as strings is not supported in PowerApps. If you want this feature, please submit an idea to PowerApps Idea forum.

Best regards,

Sik

View solution in original post

Highlighted
Frequent Visitor

Re: How to expand a variable to a screen name for Navigate?

@v-siky-msft:  Thank you for your response.

 

The distinction between a control name and it's 'string name' isn't very intuitive, but your screenshots showing that they are different data types was helpful.

 

Cheers!

Helpful resources

Announcements
Ignite

Microsoft Ignite

This will be a conference that you do not want to miss!

secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (4,398)