Model-driven apps provides a rich set of client APIs to interact with form objects and events to control what and when to display on a form. The JavaScript functions react to different events so that the code gets executed when the event occurs on the form.
The process of associating a function to an event is done manually for each form. We will see on this blog an interesting method to execute a JavaScript function on all the CRM forms without registering them manually.
Scenario: Open all lookups in a modal dialog across the CRM

Based on Microsoft’s recommendations, we can implement this scenario on a single form by registering the “onLoad” function on the “onLoad” event on the form account as an example:
We will generalize the same feature across the CRM. To achieve this functionality, we will use the CRM ribbon. Indeed, we will create a dummy hidden button that will be placed on all CRM forms using the ribbon application, and we will inject our logic into a custom enable rule.
Ribbon Configuration:

Custom Enable Rule:
According to this approach, the function “MEA.Utilities.onLoad” will be executed each time a form is opened in the CRM. As a result, all lookups will be opened as a modal dialog across the CRM.
Its very interesting. I am bit confused on how we can add a ribbon on all CRM forms. Like i know we can add it on specific table forms, but on all forms- i am bit lagging in that area !!
LikeLiked by 1 person
I added the Application Ribbon component to my solution instead of a specific entity. Please refer to this blog for more details about the Application Ribbon component: https://community.dynamics.com/crm/b/exploringdynamics365/posts/application-ribbon-in-dynamics-or-how-can-we-add-a-button-to-all-entity-forms
LikeLiked by 1 person
Thanks man! that helped. Its quite amazing idea.
LikeLiked by 1 person