In a model driven app form, I am looking to have a button in a section of the form that allows for a dialog popup to show a custom page.

Here is my HTML Code:
<!DOCTYPE html>
<html>
<head>
<title>Custom Dialog Launcher</title>
<style>
.custom-button {
background-color: blue;
color: white;
border: none;
padding: 10px 20px;
border-radius: 15px;
cursor: pointer;
font-size: 16px;
}
</style>
</head>
<body>
<button class="custom-button" onclick="openCustomDialog();">Launch Custom Page</button>
</body>
</html>
Here is the javascript code that I have as a web resource that is in an On-Load event for the form:
function openCustomDialog() {
var pageInput = {
pageType: "custom",
name: "your_custom_page_logical_name" // Replace with the logical name of your custom page
};
var navigationOptions = {
target: 2, // Open as a dialog
width: { value: 50, unit: "%" },
height: { value: 80, unit: "%" },
title: "Your Dialog Title" // Replace with the title for your dialog
};
if (Xrm.Page && Xrm.Page.navigation) {
Xrm.Page.navigation.navigateTo(pageInput, navigationOptions).then(
function () {
// Called when the dialog has been opened successfully
},
function (error) {
// Handle error
console.error("Error opening custom dialog:", error);
}
);
} else {
console.error("Xrm.Page is not available.");
}
}
When clicking on the button - I get a console log of:

Any thoughts?