Posts

Open a Custom Page either in a dialog or full screen within a Model-Driven App.

Shambhu Tiwary


Upon clicking a Ribbon (Command Bar) button, the objective is to open a Custom Page either in a dialog or full screen within a Model-Driven App.
🔹 **Prerequisites:**
1. Ensure a Custom Page is constructed and integrated into your solution.
2. Have the capability to modify the Ribbon/Command Bar using the Modern Command Designer or Ribbon Workbench.
3. Ability to include and enlist JavaScript web resources for functionality.

To achieve this, utilize the 'navigateTo()' client API in conjunction with a JavaScript web resource linked to the button. This combination enables the seamless opening of the desired Custom Page based on user interaction.

 JavaScript Code to Open a Custom Page

//CRM Crate - JavaScript Snippet.
function callMethod(executionContext) {
    formContext = executionContext.getFormContext();
    var recordId = formContext.data.entity.getId();

    //Initiating Web Resource Parameter.
    var pageInput = {
        pageType: "custom", // Set pageType as "custom"
        name: "cc_assignercustompage_96e63", // Custom Page Name
        entityName: "cc_subscriber", // Entity Name
        recordId: recordId // Input Parameter For Custom Page
    };

    //Declaring HTML Page Dimensions.
    var navigationOptions = {
        target: 2,
        position: 1,
        height: 720,
        width: 600,
        title: "CRM Crate Custom Page" // Enter Title Of Your Choice
    };

    //Using navigateTo Client API.
    Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
        function success() {
            // Run code on success
            formContext.data.refresh();
        },
        function error() {
            // Handle errors
            formContext.data.refresh();
        }
    );
}
Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.