Is there a way to register an OnLoad() handler in code?
Ex:
A script is added as a Form Library (Customize Form etc.). It contains code that wants to be executed only after the form is loaded. I suppose it can be done by using setTimeout() / setInterval() – and check Xrm.Page.data object or so, but is there another way?
First, why do you want to do it programmatically ?
Otherwise, you can do it programmatically by using jQuery. Like this :
Of course, you will have to add jQuery in your form’s libraries.
Be careful using jQuery ready event. The data is retrieve asynchronously. The jQuery ready event may fire before the CRM is finished loading.