Side Pane with Entity Form in Dynamics 365

Introduction

In Dynamics 365, if you're looking to call a JavaScript function, APY.Account.LoadPromotions, at different events or on various actions within the Account Entity Form, you'll need to configure these triggers in the appropriate context.

Here's how you can set up different triggers for calling APY.Account.LoadPromotions.

OnLoad Event

Open the Account Entity Form in Dynamics 365.

Navigate to the Form Editor.

In the Form Editor, select the Account Related Contact Side Pane.

There should be an option to set events or actions associated with the OnLoad event for this specific pane or HTML Page. Configure it to trigger the APY.Account.LoadPromotions JavaScript function on the OnLoad event of this specific element.

OnChange Event

If you want to trigger the function on a specific field change within the Account Entity Form, navigate to the Form Editor.

Select the field you want to trigger the function on change for.

Find the properties or events associated with that field and set up the OnChange event to call APY.Account.LoadPromotions.

OnSave Event

For triggering the function on saving the Account Entity Form, you can use form-level events.

Go to the Form Properties or Events section in the Form Editor.

Look for the OnSave event and associate it with the APY.Account.LoadPromotions function.

Ribbon Button Click

If you want to trigger the function on a Ribbon Button Click, you'll need to customize the ribbon.

Go to the Ribbon Workbench or Customizations and create a custom button.

Associate an action or command with this button, and in that action/command, call the APY.Account.LoadPromotions JavaScript function.

Ensure that the APY.Account.LoadPromotions function is correctly defined and accessible from the form context. Always test your changes after configuring these triggers to ensure they work as expected in the Dynamics 365 environment.

Here I have registered the Event on OnLoad of Form with the function name APY.Account.LoadPromotions.

Create a Javascript Webresource with below Code

var APY = APY || { namespace: true };
APY.Account = APY.Account || { namespace: true };

APY.Account.LoadPromotions = function (executionContext) {
    "use strict";
    try {
        var formContext = executionContext.getFormContext();
        var qs = "accountid=" + formContext.data.entity.getId().replace('{', '').replace('}', '');

        Xrm.App.sidePanes.createPane({
            title: "Contacts View",
            imageSrc: "WebResources/sample_reservation_icon",
            paneId: "ContactList",
            canClose: true
        }).then((pane) => {
            pane.navigate({
                pageType: "entitylist",
                entityName: "contact"
            });
        });
    } catch (e) {
        APY.Common.ShowAlertDialog("Ok", e.message + "An error occurred. Please contact your System Administrator", "Error Dialog");
    }
};

We can Display My Active Contacts View by Using the Side Pane

Test

We can Display Contact records by Using the Side Pane

var primaryContact = formContext.getAttribute("primarycontactid").getValue();

//"d8393ace-8726-ec11-b6e6-000d3ac9b3f7",
Xrm.App.sidePanes.createPane({
    title: "Contact Record",
    imageSrc: "WebResources/Contast_Icon",
    hideHeader: true,
    canClose: true,
    width: 600
}).then((pane) => {
    pane.navigate({
        pageType: "entityrecord",
        entityName: "contact",
        entityId: primaryContact[0].id,
    });
});

 Display Contact records

We can Display the Dashboard in the Side Pane

Xrm.App.sidePanes.createPane({
    title: "Contact Record",
    imageSrc: "WebResources/Contast_Icon",
    hideHeader: true,
    canClose: true,
    width: 600
}).then((pane) => {
    pane.navigate({
        pageType: "dashboard",
        dashboardId: "2701de60-8f2a-48a4-8262-4a35ca7441fa"
    });
});

Display the Dashboard

We can display the web resource Page with a Side Pane

Xrm.Panel.loadPanel(
    "https://org54c694bf.crm8.dynamics.com/main.aspx?etc=9333&pagetype=webresourceedit&appSolutionId=%7bC0F8C6B4-8526-EC11-B6E6-000D3AC9B3F7%7d&id=%7b7A38978D-8626-EC11-B6E6-000D3AC9B3F7%7d&_CreateFromType=7100&_CreateFromId=%7bC0F8C6B4-8526-EC11-B6E6-000D3AC9B3F7%7d#617662553",
    "Landing Page"
);

display the web resource Page


Similar Articles