Andrew N
Andrew N

Reputation: 521

Dynamics CRM Form OnLoad Event - Call functions in Form or in OnLoad Event

I've taken over from another Dynamics CRM developer and noticed that they have a JS script file as a form library. They have then registered multiple functions from the script library with the Form's OnLoad event using the Form Properties window. The same could have been achieved by calling an onLoad function in the script file and calling those other functions inside the onLoad function. They both are the same but I wanted to know if anyone can think of reasons why one method is better than the other or viceversa?

Thanks.

Upvotes: 0

Views: 2399

Answers (1)

James Wood
James Wood

Reputation: 17562

This is a subjective decision, I'm not sure one is really better than the other.

Having a single on load function that calls all other functions has a nice simplicity, and enables control via code.

Registering the functions individually has a few additional benefits:

  • Gives a clear visibility via the form properties window of what is registered on load. This could be especially helpful to non-coders.
  • If the JavaScript file was a shared file used across multiple forms, this allows someone to 'pick' parts of a file.
  • Allows individual functions to be registered and unregistered easily without having to change the code. This could be helpful for debugging issues or working on items in isolation.

Upvotes: 0

Related Questions