How to Show Dynamics 365/ CRM form in a modal window? use Xrm.Navigate.navigateTo

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

With PowerApps release wave 1 2020, Microsoft have released quite a few features under the hood. While some  have hogged the limelight, others continue to evolve in the platform like hidden gems. And one of them is the enhancement in much loved Xrm.Navigate.navigateTo API.

Now with this API you can open an entity record modal and that too with the choice of form you want.

Advertisements

While this blog teaches you on how to do all this using sample code, this kind of feature is actually going to save you loads of time. Imagine you wanted to show specific record form as modal while working on something else. And previously you would require to develop a HTML web resource and map the values back to D365 record. Now you can just use few lines of code to do the same.

Below the sample code piece to open a contact record. Please note as of the current version, only form of type Edit is supported.

Xrm.Navigation.navigateTo({
pageType: “entityrecord”,
entityName: “<put your entity logical name here>”,
formType: 2, // you can only open a form in edit mode as of now. Other form types are not supported.
entityId: <put your record id here>
}, {
target: 2,
position: 1,
width: 700,

       height:600
});

Advertisements

And below is what you see.

image

Awesome isn’t it? Now one problem here is the record will open on the default form. What if you want to open the record in a form of your choice. Well here you go.

Xrm.Navigation.navigateTo({
pageType: “entityrecord”,
entityName: “<put your entity logical name here>”,
formType: 2, // you can only open a form in edit mode as of now. Other form types are not supported.

    formId: “<put your formid here>>”
entityId: <put your record id here>
}, {
target: 2,
position: 1,
width: 700,

       height:600
});

Advertisements

I wrote some code to open it in Information form as you can see below, it did just that

image

Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s