MS @ Solution Point

Madhusudan has domain exposure in different verticals i.e. Manufacturing, Logistics, IT Service Management, Health Technologies, Real Estate, Life Insurance etc., and these days working in Aviation having overall 20 + years of industry experience with 8+ years of MS Dynamics and Power Platform.

Open a record in a Main Form Dialog (MFD) for Model-Driven App

Open a record in a Main Form Dialog as pop up of available window or side pane

With the April 2020 Wave 1 release which is now available in India Geo by Microsoft of D365 Unified Interface for model-driven apps in Power Apps, a new feature has been added in client API where you can now open a record in a dialog on main form. Here I have tried explaining you a use case, may help you understand the feature.

We came across to various discussion with our customers where they do not wish to navigate away from the current screen, and wanted to access maximum out of it being active on same screen, so this is a step ahead to fullfill the requirement.

What is Main Form Dialog !

Main Form Dialog (MFD) is a feature using with users would no longer need to navigate away from a main form. This feature now allows users to be able to open a related record entity on a parent or base form itself.

Users can stay in same form context and edit an existing record or create a new one for the opened entity. Which made it easy to access the records and adaptability.

How to use !

This feature will be supported using the navigateTo api’s and can be called writing simple api code using java script from the command bar, an event, a subgrid, a lookup, or from a plugin.

Like below, is an example of Contact record opened in a Main Form Dialog (MFD) from an account record.

The record will open in a modal dialog and users will have access to the relevant command bar, header fields and tabs that is defined for the record’s main form while designing the form in Dynamics.

Contact entity MFD
Contact entity opens in MFD

Open main form in a dialog using client API

To open the main form in a dialog using client API, you need to invoke the call using the reference of Xrm.Navigation.navigateTo method with several parameters and extends options, including the size and position to show the dialog on user screen.

Important to know:

  • Opening main form in a dialog using client API is still in preview, so you can try it on Sandbox.
  • Preview features aren’t meant for production use yet and may have restricted functionality for now. These features are available before an official release so that users can get early access and benefitted.

Examples

1) Open a new record

In this example, we will try to open a new record.

Code
Xrm.Navigation.navigateTo({pageType: ”entityrecord”, entityName: ”account”, formType: 2}, {target: 2, position: 1, width: {value: 50, unit:”%”}});  

Open a new record

The dialog opens in the Center using upto 50% of available window as a Model on top of the form with a new account form for creating a new record.

2) Open an existing record

In this example, we will try to open an existing record.

Code
Xrm.Navigation.navigateTo({pageType:”entityrecord”, entityName:”account”, formType:2, entityId:”xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”}, {target: 2, position: 1, width: {value: 80, unit:”%”}});  

The dialog opens an existing account record using the account entity id value over the contact form.

Replace the entity id with any record id GUID value.

3) Open a new record on the side pane

In this example, we will try opening in side pane.

Code
Xrm.Navigation.navigateTo({pageType:”entityrecord”, entityName:”account”, formType:2}, {target: 2, position: 2, width: {value: 500, unit:”px”}});  

The dialog opens a new record in the right corner of the window. This can be achieved by using the pixel options (i.e. 500px as width)

4) Open main form in a dialog with callback method

This example shows how a main form dialog is invoked with a callback method after saving a record and closing the dialog.

Code
Xrm.Navigation.navigateTo({pageType:”entityrecord”, entityName:”account”, formType:2},{target: 2, position: 2, width: {value: 80, unit:”%”}}).then( function (retVal) {         console.log(retVal.savedEntityReference[0].id + “, ” + retVal.savedEntityReference[0].name)
            },
            function (error) {
                         console.log(error);
            });
 

You can easily access the record I’d post successfully data saved, and can perform some action on success/error call back.

Design a site like this with WordPress.com
Get started