Skip to main content

Deep Linking in PowerApps

Headshot of article author Mehdi Slaoui Andaloussi

A common scenario when building apps is to enable deep linking into specific screens within your application. In the example below, we have a catalogue of devices that you can browse, look at the detail view of a particular device, and share.  For this example, sharing could simply send an email with a link to a particular device. To enable this scenario, let’s start with how you would construct a URL in power apps:

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

The appId is the unique Guid number representing this app.  To get the appId, you will need to save the app to the cloud, and go to web.powerapps.com and navigate to the 'Details' page:

deeplink

image

The query can be an arbitrary key value pair. In our case let’s use machineId=x where x is the device id of the product we want to share. As an example here, the URL for the device with machineId = 1.

https://web.powerapps.com/apps/7caeaf77-6dd9-df61-053a-7b3c5b3d3bc8?machineId=1

Now that we have constructed the URL, let’s wire up our app. First, let’s start with the 'Share' button’s OnSelect property in the 'DetailScreen':

Office365.SendEmail(recipient, subject, "https://web.powerapps.com/apps/7caeaf77-6dd9-df61-053a-7b3c5b3d3bc8?machineId=" & device.MachineID)

 

image

Next, let’s add the logic to deep link into the detail screen if we detect that the app was launched with the machineId parameter as part of the URL. For that, we will insert a timer control in the home screen, and add the following to the 'OnTimerEnd' property:

If(Not(IsBlank(Param("machineId"))),Navigate(DetailScreen, Cover,{device:LookUp(Machines, MachineID = Value(Param("machineId")))}))

The Param function here is what we use to retrieve the query string parameter if one was supplied when launching the app.

We also set the 'Duration' property to a shorter duration say 600ms, 'AutoStart' to true and the 'Visible' property of the Timer to false.

image

That should be it. If you run using a link like this https://web.powerapps.com/apps/{appId}?machineId=1 , you should see the app open directly  into the detail view.

Check out the sample app here (when you open the app, make sure to add a static data source using the excel file)