In this post, we will look at an issue in Dynamics 365 and HTML web resources. This is a known issue according to the community forums that Microsoft has said to be working to resolve, and may already be resolved in your org. If you’re having this issue, it’s likely your org does not have the fix and you can try below.
The issue is, when an HTML web resource is uploaded, the Dynamics 365 Power Apps platform is adding encoding and breaking the HTML, so what was uploaded is different to what is in the system. This leaves the HTML uploaded unusable.
Let’s look at an example of this and what worked for me to fix it.
First, here’s an example of an HTML web resource. It is a simple HTML page which has a button that, when clicked, displays Hello World:
Here’s what should happen when the page is displayed. A button is rendered and on clicking, the page displays “Hello World”:
Now, here’s our web resource in Dynamics 365. Let’s add the code:
We’re pasting in the code like this:
Now let’s click on the Rich Text tab:
And back to the Source tab. We see the HTML has changed significantly:
If we save and publish this, we see the source in the browser as:
Some fixes the community has reported working as include:
- Using the Upload button to upload HTML instead of using the Dynamics 365 editor
- Using the editor to create the code, but then saving the web resource and publishing from the solution, not the web resource itself
What worked for me (at least with some tests I ran on my files) was to add the following line to the web resource:
And then additionally, using the Web Resource Manager plugin in the XrmToolbox to upload and publish the code:
In doing it this way, we end up with clean HTML after it is uploaded, and the code is working as expected.