Omar El-Anis – 365 Developer

My experiences with SharePoint, Flows, PowerApps, JavaScript and all of the other lovely web technologies out there!

Office 365 PowerApps

PowerApp using URL parameters to open a specific screen on load

When building PowerApps one extremely useful feature available to developers is the URL parameters feature that allows parameters to be passed into the application on load from the URL.

In this article we will look at using such a parameter to load a specific screen when the application loads.

Why would you need something like this?

Let’s imagine you have created a really cool app with lots of screen and features but you also want to be able to direct people to specific parts of the app instantly, so let’s say I have a button on a page somewhere that says “Policies” and I want any users clicking on that button to be directed straight to the screen “Policies” within my PowerApp.

So a few steps will happen here:

  • User clicks on the button
  • Browser screen opens up PowerApp
  • Applications loads and instantly takes the user to the “Policies” screen
  • The user is happy as they have found the content they wanted!

So how do we set this up?

It is actually very straight forward to set this up, just follow the steps below:

1) Open the PowerApp in question in Edit mode

2) Click on “App” from the navigation menu on the left of the screen

3) Select the function “OnStart” form the dropdown menu on the left

4) Enter the following into the load box:
Set(firstRun, true)

This will be used to make sure the user doesn’t get redirect everytime they visit the homepage whilst still in the app

5) Click on “Insert” tab and then click on “Controls”

6) Click on the “Timer” object to add it to your project

7) Click on the newly created timer and select the function “OnTimerStart” and enter the following into the value box:

If(
firstRun=true,
Set(firstRun, false);
If(Param("screenID")="meaningfulName", Navigate('SCREEN NAME', ScreenTransition.Fade));
)

Replace "meaningfulName" with an identifier that will be used in the URL to pass the parameter to the app

Replace 'SCREEN NAME' with the name of the screen you want the user to be redirected to on load

That’s it from within PowerApps! You can now save and publish the App.

Now simply add &screenID=meaningfulName (replacing meaningfulName with the name you choose to use in the previous steps) to the end of the URL used to open your PowerApp.

For example:

https://web.powerapps.com/webplayer/app?source=portal&screenColor=rgba(0%2c+134%2c+208%2c+1)&appId=%2fproviders%2fMicrosoft.PowerApps%2fapps%2f000000-0000-4400-00000-0000000&environment-name=Default-000-0000-000-000&screenID=meaningfulName

The App will auto load whicher screen you set “meaningfulName” to load

 

LEAVE A RESPONSE

Your email address will not be published. Required fields are marked *