Open Lookup Records in Main Form Dialog

With the new Wave 1 2020 release, Microsoft released many new exciting features for its users. In this blog, we will be discussing one of these new features which aims to help the end-user. This feature will allow the user to open a lookup record in a dialog. The user can also perform further actions like edit and save the record without opening the record. Dynamics users need this functionality to avoid the extra headache of navigating back and forth. Previously, many users have implemented this functionality using custom logic, but Microsoft has introduced this feature to help you do that easily and quickly.

 

Learn more about our Microsoft Dynamics 365 services

 

You can read more about applying business logic using client scripting in the official Microsoft documentation:

With this feature, we can override the existing onClick functionality using addOnLookupTagClick and then provide the desired settings for opening the form. This is a very new and exciting functionality that we can achieve by combining Navigation and addOnLookupTagClick.

Take a look at this GIF of the UI after the implementation of this feature.

To achieve this functionality, you must add JavaScript code on the form “on load” event and change the lookup field. This will override the existing event with a new “on load” event for the form. When you click the lookup value, this unique event will block the default event, and the newly registered event will trigger with the provided settings for the form dialog.

 

Learn more about our Microsoft Dynamics 365 services

 

Below you will find the JS code. You must register the “on load” function on form load and change the lookup field.

function onLoad(executionContext) {    var formContext = executionContext.getFormContext();    var lookupControl = formContext.getControl(“parentcustomerid”);    lookupControl.addOnLookupTagClick(onLookupClick); } function onLookupClick(executionContext) {    executionContext.getEventArgs().preventDefault();    var record = executionContext.getEventArgs().getTagValue();    Xrm.Navigation.navigateTo({        pageType: “entityrecord”,        entityName: record.entityType,        entityId: record.id    }, {        target: 2,      //2 – Open record in modal dialog        width:         {            value: 80,             unit: “%”         }    }); }

One thing to check before implementing this functionality, you should double-check if you have the 2020 release one update activated. Without the update activated, this may not work as expected.

I hope this blog has helped you understand the lookup feature in the new release wave of Dynamics 365. If you have any questions, insights, or queries about this blog, feel free to leave a comment using the text box below! We will get back to you ASAP.

If you have any question or queries, do not hesitate to reach out to us!Â