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.
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
});
And below is what you see.
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
});
I wrote some code to open it in Information form as you can see below, it did just that
Hope this helps!
You might also like the below posts
Debajit Dutta
(Dynamics MVP)
For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com
Discover more from Debajit's Power Apps & Dynamics 365 Blog
Subscribe to get the latest posts sent to your email.