Power Apps: Deprecation of Navigation Function in App’s OnStart

  • Introduction
  • Workaround
  • Use the StartScreen Property
  • Summary

 

Introduction

One of the common ways to switch screen or set the start screen was to use the App.OnStart to specify the Navigate function that will show the specified screen on start up. 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.

“Navigate is not permitted in OnStart. Use the Start Screen property instead”

Workaround

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 with Query Parameter View as Admin.

https://apps.powerapps.com/play/4002208c-8de3-41a4-b29b-774d69378fb8?tenantId=b3629ed1-3361-4ec4-a2b7-5066a5c5?View=Admin

It will switch Navigate to the Admin Screen of the app

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 work around will work but the advised way to move forward is to use the Start Screen Property

Use the StartScreen 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

If(Param("View")= "Admin",Screen_AdminView,Screen_NurseView)

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.

Lets test with the Nurse Query parameter link and we can see that the StartScreen Property has set the Nurse screen as the start screen

https://apps.powerapps.com/play/4002208c-8de3-41a4-b29b-774d69378fb8?tenantId=b3629ed1-3361-4ec4-a2b7-5066a5c5fa?View=Nurse

Summary

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.