Monday 27 April 2020

Open subgrid record as a Modal Popup in Dynamics 365

Hi Everyone,

The most awaiting feature Modal popups are available in Dynamics 365 now and made our lives easier for many things, we are getting many requirements to open the records as a popup where we have control on the parent record and hence not loosing the changes.

One of the requirement I heard today was opening the record as popup from Subgrid. Initially we thought there is no way but after quick check we are done with the job with the help of the Editable Grids.

Let's say there is a subgrid on Account as Contact and whenever user selects the record we can make use NavigateTo function and open the selected record as a popup. We have to put below code on the RecordSelect event of the subgrid.

function onRecordSelect(executionContext) {
    var selectedRecord = executionContext.getFormContext().data.entity;
    var Id = selectedRecord.getId();
    var entityName = selectedRecord.getEntityName();
    var pageInput = {
        pageType: "entityrecord",
        entityName: entityName,
        entityId: Id
    };
    var navigationOptions = {
        target: 2,
        height: { value: 70, unit: "%" },
        width: { value: 70, unit: "%" },
        position: 1
    };
    Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
        function success() { },
        function error() { }
    );

}


Hope this helps.

--
Happy 365'ing
Gopinath

No comments:

Post a Comment