cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CMetcalfe
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
v-siky-msft
Community Support
Community Support

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

6 REPLIES 6
mdevaney
Super User III
Super User III

@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."

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.

@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."

 

v-siky-msft
Community Support
Community Support

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

@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!

rschneider
Advocate II
Advocate II

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

PA Community Call

Power Apps Community Call

Next call is happening on April 21st at 8a PST.

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (60,510)