Client Scripts: onLoad vs. onChange

gauravchoudhury
Tera Guru

Currently I am new to ServiceNow and I trying to understand from a conceptual level on the significance and purpose behind various scripting. Apart from the usual text book definition of onLoad and onChange scripts, how would we different the significance, purpose or usage between these two scripts?

Regards,

Gaurav Choudhury.

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Gaurav,



  • onLoad means the Client Script runs when the form or page is loaded
  • onChange means the Client Script runs when something specific gets changed AND also when the form or page loads

Additional parameter for onChange client script is : isLoading - identifies whether the form is loading and also indicates that no fields have changed value. This parameter can only be true when the form is loading and no values have changed.



http://wiki.servicenow.com/index.php?title=Client_Scripts


View solution in original post

5 REPLIES 5

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Gaurav,



  • onLoad means the Client Script runs when the form or page is loaded
  • onChange means the Client Script runs when something specific gets changed AND also when the form or page loads

Additional parameter for onChange client script is : isLoading - identifies whether the form is loading and also indicates that no fields have changed value. This parameter can only be true when the form is loading and no values have changed.



http://wiki.servicenow.com/index.php?title=Client_Scripts


Why do we need onload client script when onchange can run on load? Execution of part of code can be controlled by isLoading.

Midhun1
Giga Guru

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hey Gaurav,



Let me know if that answered your question. If so, please mark it as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list. Thank you