Deep Linking in Power Apps

A common scenario in using any application is to directly access a specific screen within the application without landing on the home page first. This feature is called Deep Linking and it greatly helps to improve the efficiency of the workflow.

For example, if you want to show someone the Google search results of a certain search item, instead of asking the user to go to Google home page and manually key in the search item, you can send him the link below which upon clicking will directly show the search results page, saving time and avoiding possible mistakes.

https://www.google.com/search?q=searchitem

Power Apps does support Deep Linking and we are going to demonstrate how to open a specific screen with a specific record.

Configure Power Apps to Accept Parameters upon Launch

One important step to make Deep Linking work is to allow Power Apps to take in parameters upon launch. To do this, we need to modify the properties related to the app itself. In the Power Apps studio, select the “App” section of the Tree View and click on the Property drop down list. These properties define app level behaviors.

The properties we are going to use here for Deep Linking are OnStart and StartScreen. For those who used Deep Linking in Power Apps before, you used to write the Navigate function inside the OnStart property. However following an announcement made by Microsoft on 20 Oct 2021, going forward, Navigate cannot be called in OnStart property and developers should use StartScreen instead to define the app launch page. However the app can still collect other parameters of the Deep Linking in the OnStart execution, like the record you want to show on the screen.

The function used to extract the parameter value is simply called Param(ParameterName), where ParameterName is the name you defined for the parameter passed to the app.

In the OnStart property, use Set to assign the Record parameter to a variable called varRecord.

Set(varRecord, Param("Record"))

Then in the StartScreen property, using an If or Switch function to deicide which screen to navigate to based on the value of parameter Screen. Each row here defines one navigation with the form of “parameter-value-in-deep-linking”, in-app-page-name,. The last row means in the case that there is no Screen parameter value specified, the app will go to Screen 1 by default.

Switch(Param("Screen"),
    "Screen1", Screen1,
    "Screen2", Screen2,
    Screen1
)

Now create the Screen2 and insert a form to display the record of selection. After connecting the data source, put below formula in the form’s item property to show the record based on the value of parameter Record stored in the variable.

LookUp(DeekLinkingTest,Title = varRecord)

Those who know how to use the default column ID of a SharePoint list, you can also use this column since it is a guaranteed unique index column.

Construct the Deep Linking URL

A Power Apps Deep Linking URL follows this format:

https://web.powerapps.com/apps/{appId}?{query}

appId is the unique Guid number representing this app, which can be found in the app details page. query is the set of arbitrary key value pairs based on parameters defined by you. In this demo, the two parameters you can include are Screen and Record.

So if we want to directly go to Screen2 and let the page display Record2. We should construct URL as below. Do take note that both the parameter names and parameter values are case sensitive. So screen=Screen2 is different from Screen=Screen2.

 https://web.powerapps.com/apps/{appId}?Screen=Screen2&Record=Record2

Works as expected!

Interesting Implications (Side Effects)

You may notice that I didn’t insert any navigation buttons on the page so the user cannot move to other parts of the app from this page. This technically makes this page an orphan page. From there we will have some interesting implications or side effects depending on how you look at them:

  1. It can allow users to directly access a page that is not accessible by moving around in app as normal, as long as the user knows the correct URL. So maybe a hidden configuration and management page for app admin only?
  2. Deep Linking leverages on altering starting page so it can bypass some of the in-app access control checks we normally used to whitelist or blacklist app users. So perhaps a user that is not allowed to use the app can still be sent a report summary page that only allows him to view or print data without being able to go to other pages?
  3. Deep Linking specifies the exact page and record to display regardless how the display rules were set in the app. So for an app that only displays pending items, you can still use a Deep Linking to pull out a closed item that is not supposed to be shown in the app anymore.

Leave a Comment