Powered By Blogger

Tuesday, July 25, 2023

Dynamics CRM - Open the Modal pop-up form from new “Power Apps grid control”

As we now know that in April 2023 new feature has been released which is “Power Apps grid control”. So, now we can now convert any subgrid/view in Dynamics 365 CRM as "Power Apps Grid Control". And, This control will eventually replace all read-only and editable grids in model-driven apps. Click here to read more about “Power Apps grid control”.

So, now the question is - How can we open any modal pop-up form on record click of subgrid without actually opening the record in full view and also without making that grid editable?

The answer is- 

Step 1: We first need to change the control from the "Read-Only grid" to the "Power Apps grid control".


Step 2: Go to Events and Select Event as "OnRecordSelect" and add then add the library and check the "Enabled" and "Pass execution context as first parameter" checkboxes.





Step 3: Add method in the Script. Below is the code you can use to call modal pop-up form on record select from the subgrid:

var ArpitaD365Learning= window.ArpitaD365Learning|| {};

(function () {
    this.onRecordSelect= function (executionContext) {
        try {
            var pageInput = {
                pageType: "entityrecord",
                entityName: executionContext.getEventSource().getEntityName(),
                entityId: executionContext.getEventSource().getId(),
                // Add the GUID of the form which you want to open in the modal form
                formId: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
            };

            var navigationOptions = {
                target: 2,
                height: { value: 70, unit: "%" },
                width: { value: 70, unit: "%" },
                // position 1 for dialog in the center, 2 for the far side
                position: 1
            };

            Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
                function success() {
                    console.log("Success log");
                },
                function error() {
                    console.log(error.message);
                });
        }
        catch (error) {
            console.log(error.message);
        }
    }

}).call(ArpitaD365Learning);

No comments:

Post a Comment

Tools for Unit Testing in Power Platform