How to execute a JavaScript function on all forms without registering it manually?
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.
Demo:
This was originally posted here.
*This post is locked for comments