A developer wants to use ServiceNow Studio to create a client script that runs when a form loads and sets a field value based on the current user's department. Which type of client script should be used?
onLoad runs when the form is opened.
Why this answer
An onLoad client script runs automatically when a form is opened, making it the correct choice for setting a field value based on the current user's department at the time the form loads. This script type executes in the browser after the form data is retrieved but before the user interacts with the form, allowing immediate field population.
Exam trap
The trap here is that candidates may confuse onLoad with onChange, thinking a field change event is needed to set a value, but the requirement explicitly states 'when a form loads', which directly maps to the onLoad client script type.
How to eliminate wrong answers
Option B is wrong because an onChange client script triggers only when a specific field value changes, not when the form initially loads, so it cannot set the field value on form open. Option C is wrong because an onSubmit client script runs when the form is submitted, which is too late for setting a value on load. Option D is wrong because an onCellEdit client script is used in list or grid views for inline cell editing, not for form load events.