One of the common ways to switch screens or set the start screen was to use the App.OnStart to specify the Navigate function that will show the specified screen on startup. In case we are passing a Query parameter via weblink that opens up the Power App, the Param function could have been used to get the query parameter value based on which we used to Navigate to that specific screen.
However, Navigate function is being deprecated in the OnStart of the App considering performance reasons and if we try to use the Navigate function in the Onstart, we will get the below error message. Here we are trying to get the Query String Parameter Value “View” using the Parm function and Navigate to the corresponding Screens.
|“Navigate is not permitted in OnStart. Use the Start Screen property instead”|
In case you have too many apps which were created before March 2021 and you need more time to make the changes by switching over to the Start Screen Property which obviously involves end to end testing as well, one of the workarounds that may work for a while is to re-enable Navigate function.
Note: Re-enabling the Navigate is not a recommended approach as it is deprecated and will put your application at further risk.
We can re-enable the Navigation within the OnStart property by heading over to File->Setting->Upcoming Features->Retired
Here, toggle the Off button in Enable Navigate function in App.OnStart to On
Now the Navigate function will still work and we can test it by hitting the Power App link that contains a Query Parameter named View with value as Admin.
It will Navigate to the Admin screen of the app as we have added the Parm Function to get the View Query parameter and Navigate to corresponding screens in the OnStart Property.
Same way If we use the URL with Query parameter nurse, it will Navigate to the Nurse View of the App. Thus, for now, this workaround will work but the advised way to move forward is to use the Start Screen Property
The best practice and the way forward is to use the StartScreen Property and not enable navigation in the App.OnStart. The same formula that we used in the OnStart can be changed to suit the StartScreen property as
Here the expression checks the query parameter named View and if its value is Admin, it sets the Admin Screen as start screen else it sets the Nurse Screen as start screen.
Let’s test with the Nurse Query parameter link and we can see that the StartScreen Property has set the Nurse screen as the start screen
Thus we saw how to temporarily enable Navigate function in the App.OnStart and how to use the StartScreen Property to implement the workaround for Navigate functionality when the App starts up.