Skip to main content

Registering Form Event Handlers In JavaScript

Something I have started looking at recently is registering form event handlers within the code. I personally think it allows anyone to review the form to quickly seeing all event handlers in one place without having to flick through both the form and the JavaScript file. This is done using



I would usually call separate register handlers function on form load to register all my handlers. Example below

// OnLoad function called from the from event handler
function OnLoad (executionContext){
    //do other on load stuff
    //rigster all handlers
function RegisterHandlers(executionContext){
    var formContext = executionContext.getFormContext();
function my_fieldname1_Onchange(executionContext){
    //do on change stuff
function my_fieldname2_Onchange(executionContext){
    //do on change stuff
function OnSave(executionContext){
    //do on save stuff

At a glance this allows you to see which fields have on change functions registered on them and make changes in one place

Charles Osei

Dynamics 365 Consultant @ Hitachi MCSE Business Applications Computer Science ā€“ University of Lincoln 2017 Nottingham D365/CRM user group Chapter Leader TDG ā€“ Community leader Twitter @charlied3v LinedIn

Leave a Reply