Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

what is the difference between onload client script and onchange client script.

ImmadisettyP
Tera Contributor
 
5 REPLIES 5

Raahul2
Tera Contributor
  1. Both onLoad and onChange client scripts are used to run JavaScript code on the client-side (i.e., in the user's browser,client side), but they have different purposes and triggering conditions.
  2. onLoad Client Script:
    • Trigger condition: Runs when a record form is loaded (opened or refreshed).
    • Purpose: It’s typically used to manipulate the form or perform actions when the form first appears to the user. For example, setting default values or hiding/showing fields.
    • Example: Hiding a field when the form loads.
  3. onChange Client Script:
    • Trigger condition: Runs when the value of a specific field on the form changes.
    • Purpose: It’s used to perform actions based on changes to a particular field, such as validating input or triggering other changes on the form when the field value is modified.
    • Example: Displaying a message or updating other fields when a user selects a value in a dropdown field.

Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution