Intro to Deep Linking in PowerApps

Intro to Deep Linking in PowerApps

Instead of opening an app’s main screen, there are scenarios where you’d want to directly take a user to a specific screen. This post will explore how to deep link to a specific record in both Canvas and Model Driven Apps.

Example Use Case

Consider an example where app contains Purchase Orders. When someone creates a new purchase order (PO), Power Automate sends an email to the manager with a deep link to the corresponding PO. The deep link directly to the main form for that PO.

A Deep link in an email navigating to the Main Form for ORDR-1022

Deep Linking in Model Driven Apps

To begin, I’m using a variable object named “varURLParams”, which I will later populate with the key values needed to construct the deep link.

The Dataverse table “Model Driven Apps” holds the Model Driven App’s Id we need for the deep link. Add a “Lists Rows” Dataverse Action and by filtering on this table on the app’s unique name (not the display name!) The unique name can’t be changed after the Model-Driven App is created.

You can get you app’s unique name several different ways, but I think the quickest way is to click the 3 dots (kabob) within Apps > Details. Within the URL, you will see the uniquename after the insights/guid. It is case sensitive!

My app’s unique name
Selecting just the appid column needed and filtering on the uniquename

We will construct the URL following this format:

The items in red come from the table where our record to the deep link resides while the appid in blue is coming from the Model Driven Apps table. I set the object variable from earlier using this code.

{
"EnvironmentURL": @{split(body('Get_Purchase_Order')?['@odata.id'],'/api')[0]},
"AppId": @{first(outputs('Get_Model_Driven_App')?['body/value'])?['appmoduleid']},
"EntityName": @{last(split(body('Get_Purchase_Order')?['@odata.type'],'.CRM.'))},
"RecordGUID":@{outputs('Get_Purchase_Order')?['body/bb89_purchaseorderid']}
}

You’ll need to change the Record GUID to be that of the identifier column of your row fetched earlier.

@{variables('varURLParams')?['EnvironmentURL']}/main.aspx?appid=@{variables('varURLParams')?['AppId']}&pagetype=entityrecord&etn=@{variables('varURLParams')?['EntityName']}&id=@{variables('varURLParams')?['RecordGUID']}

Finally, we can print the DeepLink to a compose action, add the and then pass that into an email. The link will take the user right to the Purchase Order Record!

Deep Linking in Canvas Apps

Canvas App Deep linking relies on the Param function and passing it in the app URL by adding &parametername=value. The parameter name itself can be whatever you decide. If the parameter is not blank when the App starts, we do something with it. Building off the previous example, we’ll pass a parameter called “OrderID” which will be the primary identifier of the Dataverse Purchase Order Record.

In the App OnStart Code, I pass the following

If(
    !IsBlank(Param("ORDERID")),
    // Lookup the the Purchase Order Record using the Parameter value passed
    Set(
        varRecord,
        LookUp(
            'Purchase Orders',
            'Purchase Order' = GUID(Param("ORDERID"))
        )
    );
    // Do Additional Actions
    Set(
        varFormMode,
        FormMode.Edit
    );
)

On the App StartScreen Property, set the following:

If(
    IsBlank(Param("ORDERID")),
    'Main Screen',
    'Order Detail Screen'
)

If your datasource is using SharePoint, you’ll want to pass a number. Instead of using the guid function, use Value(Param(“ORDERID”)) instead.

This will retrieve the record from Dataverse and load it into my form on the Order Details Screen. I’m also setting the form mode to edit as defined by the varFormMode variable set as well.

To test it out, get your Canvas App’s URL, by playing app, copy the link, and append your parameter at the end. My example would be something like https://apps.powerapps.com/play……&ORDERID=855a11ae-aa45-f011-877a-00224802cb4d

Adding the OrderID parameter takes me to that order’s record on the Order Detail Screen

To pass the deep link in an e-mail using Power Automate, it’s very similar to the Model Driven App approach. You could hard-code your Canvas App’s URL in the flow, but to make it dynamic like shown with the Model Driven App example, we will fetch the appopenuri from the Dataverse Canvas App’s table:

For this to work, your Canvas App must be part of a solution (you should be using solutions!), otherwise the app won’t be found in the Dataverse Canvas Apps table! If this is the case, see the next section for an alterative method.

@{first(outputs('Get_Canvas_App')?['body/value'])?['appopenuri']}&OrderID=@{triggerOutputs()?['body/bb89_purchaseorderid']}

Using Environment Variables for Deep Linking Without Premium Features

If your app doesn’t use Dataverse, or otherwise don’t have the ability to use a premium license, but you still want to dynamically construct the deep link, a workaround is to create a text environment variable inside a solution such as “PowerApps App ID” and paste the Canvas App ID there. On the initial solution deployment, the Canvas App won’t exist in the target environment, so use a dummy value, import the solution, copy the new App ID, update the environment variable, and redeploy. It’s a bit more work, but it’s necessary if you’re trying to make this work across environments!

The Canvas App ID to copy from the App Details Page.