Tip #1332: Open forms as a dialogs in model-driven apps

Today’s tip comes from Eric Regnier. You can send your tips to jar@crmtipoftheday.com.

One of the small but awesome new features in 2020 Wave 1 are the modal dialogs. In many implementations, common feedback we hear from customers is around UX with too many clicks or navigation between screens. With this new feature, it enhances the UX by enabling the ability of creating and editing data in forms without navigating away. And it’s available for early access so check it out!

This can be achieved by using Xrm.Navigation.navigateTo function. You can use it to create new or update existing records. Here’s an example:

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

What’s even better is that the code above will work currently but will open the record in a new window instead of modal.  So you can prep your code now and will work seamlessly when Microsoft releases it 🙂
https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-navigation/navigateto

Bonus tip: Suggest to use the left side position (parameter position = 2) to have a consistent behavior with the quick create forms. So both edit record or create new (quick create) will open on the left panel.

https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/customize-entity-forms#open-main-form-in-a-dialog-using-clientapi

Cover photo by Lina Kivaka from Pexels

13 thoughts on “Tip #1332: Open forms as a dialogs in model-driven apps

  1. Marc says:

    I cant opent entityrecord in “popup” model. I use target 2 but opens like normal record.
    I’m using this code:
    Xrm.Navigation.navigateTo({pageType:”entityrecord”, entityName:”contact”, formType:2}, {target: 2, position: 1, width: {value: 50, unit:”%”}});

    Do you have any idea because work worng?

  2. Zarko Radevic says:

    Nice, but can you do this for navigating via lookup attribute? For example I would like to open the opportunity record like this from the quote when I click the lookup link on quote form. If I can’t achieve this, I don’t see this as very useful, sure I can use it in ribbon commands, but how much that helps?

    I hope I am missing something here, thanks in advance 🙂

  3. Sudharshini says:

    Hi,

    I have opened Webresource as a modal dialog.
    Is there any way to read multiple fields from parent CRM form?
    I need to pass values of some fields from modal to parent form as well.

    Thanks

  4. NewcombR says:

    This is a great to using this on a subgrid, but the subgrid has to be editable to expose the “OnRecordSelect” event.

    https://carldesouza.com/clicking-on-a-subgrid-to-open-a-modal-form-in-dynamics-365/

    Is there a way to do this with a regular subgrid? What about a the home/main entity list view?

    • Basch says:

      An option would be to create a button which calls the JS on the subgrid with something like ‘Edit in Window’. Enable the button on select and pass the selected record to the javascript as a parameter.

  5. MN says:

    What is the advantage of using Modal Dialogs over Quick Create for creating new records?

  6. charlism says:

    Really useful functionality!

    Is there a way to open the records this way, but from a view?

    Thanks in advance!

  7. anthony dobbelaere says:

    I would love to implement this but i do not seem to find any guide on how to achieve this. I added the code as a web resource but how do i link it to my subgrid on “new” click.

  8. Larry says:

    Thanks for this great tip. We had a refresh subgrid script on any save in the subgrid that stopped working when adding the modal pop up. Is there a way to have the subgrid refresh when saving and closing the modal pop up.

Leave a Reply

Your email address will not be published. Required fields are marked *