Open an HTML file from Power Apps and host it within your solution

Recently there was a need to open an HTML file from Power Apps canvas app and to even pass URL parameters to it. It sure is easy to open a desired URL from canvas app simply by using the Launch function. However, the problem in the project was where to host the static HTML file??? All UI components in the project were implemented via Power Apps canvas apps, so it felt like overkill to have the HTML deployed onto some hosting platform such as Azure App Service. We did try various other approaches, such as hosting the file in SharePoint Online, but they didn’t work as expected (e.g. SharePoint forced the HTML file to be downloaded).

So I wanted to find out whether there was a way to host the file on Power Platform. And as it turned out, there is!

I created a test solution and validated that it works. Below are the steps to make it work for you.

First, create HTML file. I used this simple content to validate correct functionality:

As you can see, I expect all URL parameters that I need to be passed on my page as URL encoded in data parameter.

Next I need to use the HTML file as a Web resource in my solution. So, go to your solution and add one.

On the web resource edit page you can now give your resource a Name (will be part of the final URL), Display Name, Description, Type (choose Webpage (HTML)) and you can also upload your HTML file.

Save and publish you Web resource. Copy the URL value that gets generated automatically after saving.

After you have published your Web resource, you can go ahead and edit your canvas app so that a correct HTML file is opened for the user. I created the following simple app to try things out:

The code that I use to generate the URL (visible in the label) is quite simple:

https://your-d365-tenant.crm4.dynamics.com//WebResources/crd3a_TestHtmlPage?data=” &
EncodeUrl(“testparam=” & TextInput1.Text & “&testparam2=” & TextInput2.Text)

Note that the part after data= is all URL encoded! 

Then just simply open the URL when the user clicks on the Open URL button:

Launch(Label1.Text)

That’s it! This way you can deliver required static HTML files along with other parts of your solution – easy and neat!

3 Comments

  1. David Kuhl says:

    Really curious now. What does, “go to your solution and add one” mean? I’m in the Power Apps web based editor and I see no such resource or way to add one. I don’t see anything on the page I would call a “solution” either. What am I missing here?

    Like

    1. terhoantila says:

      Hi David! When you go to https://make.powerapps.com/ you should see Solutions in the left menu. (Solutions menu is not visible in Power Apps Studio.)

      Like

      1. David Kuhl says:

        Well that’s pretty interesting. I’m not currently using a Dataverse database, so I haven’t dug into any of this stuff. I had no idea you could add service elements on top of that sort of thing.

        Thanks very much for the tip!
        D.

        Like

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s