In this article, we are going to learn how we can change the start screen of the app and how we can use parameters to deep link the navigation from the start screen to the different screens within canvas app. This article explains the StartScreen function with example.
How to change Start Screen (loading screen) in PowerApps?
- By default, in PowerApps, the screen listed first in the screen menu will be the home/default screen which will open when you arrive or open the app. E.g. here, HomeScreen will open first.
- But what if instead of HomeScreen, I want to open AdminPanel or UserScreen? Is it even possible?
- You must be thinking about App OnStart property, correct? But wait, there are some limitations.
Note: You cannot use Navigate function in OnStart property.
- There is one new property of the app that you can use over here. StartScreen.
- As the name suggests, you can mention the start screen of the app over here.Note: If you keep the StartScreen property blank, by default it will take the first screen (which is default screen) from order.
- For this example, we will write AdminPanel screen, save and publish.
- When you run the app, you can notice it moves to the AdminPanel, which is second screen in the order.
- You can also test in Edit mode. Click on the ellipsis from the App and then click on Navigate to StartScreen.
- In the edit mode itself, you will be redirected to the Start screen – Admin Panel.
How to Navigate to a specific screen based on parameter?
- If you are an admin, the app will start with admin page and if you are any user other than admin, then app will open the User panel. How to achieve this?
- Here, we will target the query string parameter passed in the app URL.
- First, get the App URL from Apps >> Your App >> Details >> Web link
- We need to append a parameter in this URL. This parameter will help us to identify the destination URL. We have taken paramValue as Query string parameter and in the code, we are going to check for this parameter.Note:
Query string parameter and its value both are case sensitive, so make sure about that while using them in the code.
- Go to the StartScreen property of the app and write formula like below.
- Incase you want the code:
If(
Param("paramValue") = "admin",
AdminPanel,
Param("paramValue") = "user",
UserScreen,
HomeScreen
)
- If parameter value is admin, it will open admin screen, if the parameter value is user, it will open the user screen else it will open the default (home) screen.Note: Even if you make spelling mistake or case mistake in Query string parameters, it will open the default screen only.
- This is how you use Query string parameters in your app and manipulate the landing page. Below are a few examples, you can check the parameter added and based on it’s value it is opening a different page every time.
App restart parameter
- If app is already open in browser and if you try to open the app from a mobile device, it may not perform all the formulas that you have put in AppStart property because the app is already open.
- To overcome this problem, there is one simple heck. You can pass one parameter at the end of the URL. This will indicate the app to restart.
- restartApp=true: You need to append this to the URL