CADCertified Application Developer

Lessons › Domain 2: Application User Interface (20%) › Lesson 6

Client-side Scripting

About 16 minutes · Last checked against the CAD blueprint (January 2026): 4 December 2026

Step 1 · Learn

Scripts that run in the user's browser

Client scripts run in the browser, on a form or list. They react to what the user does, for example by showing a message or setting a field when another field changes.

Types

TypeRuns when
onLoadThe form opens, before the user can work on it
onChangeA specific field's value changes, including while the form loads
onSubmitThe form is saved or submitted; returning false stops the save
onCellEditA field is edited in a list

An onChange script receives isLoading; check it so the script does not run its logic while the form is still loading.

Client-side APIs

  • g_form works with the form: getValue(), setValue(), setMandatory(), setDisplay(), setReadOnly(), showFieldMsg(), addInfoMessage().
  • g_user describes the logged-in user: userName, userID, firstName, hasRole().
  • GlideAjax calls a client-callable script include on the server and returns the answer asynchronously, for example with getXMLAnswer().

Good practice

  • Prefer a UI policy when you only need to make fields mandatory, read-only or hidden.
  • Do not use synchronous server calls, which freeze the browser; use GlideAjax with a callback.
  • Avoid g_form.getReference() without a callback for the same reason.
  • Keep onLoad scripts light, because they slow down every form load.

Debugging

Client scripts are debugged in the browser: use the browser's developer console with console.log(), check for script errors there, and use the Field Watcher to see which scripts and policies change a field.

Exam tip: client or server?g_form, g_user and GlideAjax are client-side. GlideRecord and gs are server-side. Questions often mix them up on purpose.

Step 2 · Do

Script the loan request form

Make the form react to the user, using the right client-side tools. This is a practice environment of our own design, not the ServiceNow product. Complete the tasks in the task list.

script-editor

Step 3 · Check

Exam-style questions

Select an answer and check it. Every answer includes an explanation.