Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / xRMCenter / How To Prevent Open New For...

How To Prevent Open New Form In Subgrid In Dynamic 365

nghieppham Profile Picture nghieppham 4,753

Subgrid is a great feature in Dynamic 365, it helps users to view data in 360 view easily; however, open a new form when user double click on record sometime cause annoy. This article will explain a simple tip to use pop up home by using Xrm.Navigation.

Step 1: Enable Editable Grid On Subgrid.

Step 2: Add OnRecordSelected Event

function override_OnSelectedOnGrid(context)
{

    debugger;
    var formContext = context.getFormContext(); // get formContext
    //var frame = Xrm.Page.ui.controls.get("IFRAME_ApplicationForm");
    /*Subgrid control on contact form: */
    var subgridControl = Xrm.Page.getControl('School_Application_Subgrid');

    var rows = subgridControl.getGrid().getSelectedRows();
    var selectedItem = subgridControl.getGrid().getSelectedRows().getAll();
    // subgridControl.getSelectedRows();
    if (selectedItem.length == 0)
        return;
    /**Get record Id base on Selected Item or double click */
    var applicationId = selectedItem[selectedItem.length - 1].getData().getEntity().getId();

    var globalContext = Xrm.Utility.getGlobalContext();
    //var contactId = formContext.getAttribute("fus_studentid").getValue();
    Xrm.Navigation.navigateTo(
        {
            pageType: "entityrecord",
            entityName: "entityname", //Entity name want to open
            formId: "67b1fb55-346e-4be2-90ed-835f6da53940", //Add Form Id Want to open as pop up
            formType: 2, entityId: applicationid
        },
        {
            target: 2, position: 2, width:
            {
                value: 100, unit: "%"
            }

        }).then(
            () => {

                debugger;
                Xrm.Page.data.refresh();


            },
            (e) => {
                Xrm.Page.data.refresh();
                //put your error handler here
            });
  
}

Comments

*This post is locked for comments