Steps to Embed a HTML Page in a Model-Driven App Form
Step 1: Upload the HTML file as a Web Resource
Open your solution, then click on + New and select Web Resource.
Add your HTML code.Set the File Type to 'Webpage (HTML)', provide a Name and Display Name, then click Save.
HTML CODE:
<!DOCTYPE html>
<html>
<head>
<title>Account Info</title>
<meta charset="utf-8" />
<script src="ClientGlobalContext.js.aspx" type="text/javascript"></script>
<style>
body {
font-family: "Segoe UI", sans-serif;
padding: 20px;
}
</style>
</head>
<body>
<h2>Account Information</h2>
<p>
<strong>Record Id:</strong> <span id="id">Loading...</span><br/>
<strong>Entity Name:</strong> <span id="entityName"></span><br />
<strong>Org Name:</strong> <span id="orgName"></span><br/>
<strong>Account Name:</strong> <span id="accountName"></span></p>
<script>
function getQueryParam(param) {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get(param);
}
async function loadAccountInfo() {
const id = getQueryParam("id");
const typename = getQueryParam("typename");
const orgName = getQueryParam("orgname");
if (!id || !typename) {
document.getElementById("accountName").textContent = "Missing parameters.";
document.getElementById("entityName").textContent ="Missing parameters." ;
document.getElementById("id").textContent = "New Form";
return;
}
document.getElementById("id").textContent = id || "New Form";
document.getElementById("entityName").textContent =typename || "Missing parameters." ;
document.getElementById("orgName").textContent =orgName || "Missing parameters.";
try {
const result = await Xrm.WebApi.retrieveRecord(typename, id);
console.log(result);
document.getElementById("accountName").textContent = result.name || "Not found";
} catch (error) {
console.error("Error fetching account:", error);
document.getElementById("accountName").textContent = "Error loading data.";
}
}
// Run when page loads
window.onload = loadAccountInfo;
</script>
</body>
</html>
Step 2: Add the HTML web page in form
From the components section, select 'HTML Web Resource', search for your web resource, and add it to the page.
After adding the web resource, the form will look like the image below.
Click 'Save' and then 'Publish' the form.
Step 3: Play the Model Driven app
then click the new tab added to the form. there you can see we are able to show the data in HTML page
1. Custom Read-Only UI / Visualization
You can create a rich, styled layout that visually summarizes record data, like:
-
A business card view
-
A styled profile panel
-
KPI tiles or summary boxes
Example:
Show account name, status, total revenue with icons and colors in a beautiful format.
2. Interactive Widgets
Use HTML + JavaScript to create dynamic components not available natively.
Example:
-
Signature pad
-
Star rating control
-
Toggle buttons
-
Color picker
These interact with Dataverse fields using Xrm.WebApi
.
3. Embedded External Content
Show content from external systems or APIs (secured via authentication).
Example:
-
Embed a dashboard from Power BI or another BI tool
-
Display a user profile from an HR system
-
Load images or documents from Azure Blob, AWS, etc.
4. Form-Based Mini Apps
You can embed full mini-apps inside a form using HTML + JavaScript.
Example:
A task planner, checklist, timeline, or calendar component scoped to the current record.
These can update data back to Dataverse using API calls.
5. Conditional Logic or UI Enhancements
HTML gives you control to show/hide, animate, or format fields conditionally in ways Power Apps UI can't do easily.
Example:
Show a warning message or custom banner if a record meets certain criteria (e.g., account balance too low, overdue status).
You can even change layout or style dynamically using JavaScript.
Technologies You Can Combine
-
HTML + CSS for layout and style
-
JavaScript for logic
-
Xrm.WebApi
for reading/writing Dataverse data -
ClientGlobalContext.js.aspx
to accessXrm
from HTML -
FetchXML (optionally via
Xrm.WebApi.retrieveMultipleRecords()
)
Comments
Post a Comment