Get DataVerse record URL in Power Apps canvas apps

Hello everyone and welcome to my blog. In today’s blog I will discuss on how you can frame DataVerse record URL links in your canvas apps.

This blog target the following requirements.

  • How to get the DataVerse environment URL in Power Apps/ Power Automate?
  • How to create links for DataVerse record in Power Apps

Through my blog I share interesting tips and discuss on latest releases of Microsoft.NET technologies, Dynamics 365 and Power Platform, SharePoint and Client scripting libraries. Please subscribe to my blog to stay updated.

Let’s get started. For this blog, I have selected a very simple example. I have a gallery of contacts. When I select a record from the gallery, the user can edit the record in the app.

Additionally at the bottom of the form is the ‘View Record‘ link which allow the user to open the record in a Model driven app (encircled in yellow)

To accomplish this, we are going to take the help of a Power Automate flow. The first important step in the flow is to get the GUID of the current environment.

You can get it easily using the expression workflow().tags.environmentName.

Now I have the environment id. The next step is to get the Instance URL based on the environment id. To accomplish this, we will use the Get Environments action from PowerApps for Makers connector.

This output of Get Environments is an array containing details of all the environments that is accessible to the executing user.

The next step is obviously to filter the array based on the environment id obtained from initial step. To accomplish this, I have used the ‘Filter array’ action from the Data Operation connector.

Below is the configuration of my Filter array action.

The final step is to get the instance URL and return it back to the Power App.

first(outputs('Filter_array').body).properties.linkedEnvironmentMetadata.instanceUrl

Now I have the environment URL. The final step is to create the record URL. OnSelect of an item in the gallery, I am invoking the Power Automate flow and setting the URL of the environment in a variable environmentUrl.

UpdateContext({environmentUrl: GetEnvironmentUrl.Run().envurl})

And finally, the expression to form the record url of the contact selected from the gallery.

$"{environmentUrl}/main.aspx?pagetype=entityrecord&etn=contacts&id={Gallery1.Selected.Contact}"

Well, that’s it. You now have the record url. In similar way you can frame the record URL of any DataVerse record inside your canvas app.

I hope this helped. If you have liked the post and if this post has helped you, please subscribe to my blog.

Debajit Dutta

1 thought on “Get DataVerse record URL in Power Apps canvas apps”

  1. Ghirijha Thirumavalavan

    How does the power automate flow gets triggered? whats the triggering action ?

Comments are closed.