Lessons › Domain 6: Data Migration and Integration (13%) › Lesson 30
Scripting in ServiceNow
About 15 minutes · Last checked against the CSA blueprint (January 2026): 3 December 2026
Step 1 · Learn
When configuration is not enough
The platform's scripting language is JavaScript. Administrators should configure first and script only when the built-in tools cannot meet a requirement, but they need to know where scripts run and which type to use.
Client side and server side
| Client-side | Server-side | |
|---|---|---|
| Runs in | The user's browser | The instance's servers |
| Main types | Client scripts, UI policy scripts | Business rules, script includes, scheduled jobs |
| Typical APIs | g_form (the form), g_user (the current user) | GlideRecord (database records), gs (system functions) |
Client scripts
Client scripts run on forms in the browser. Their type decides when they run:
- onLoad: when the form opens.
- onChange: when a specific field changes.
- onSubmit: when the form is saved, for example to check values and stop the save.
- onCellEdit: when a value is changed directly in a list.
Server-side scripts
- Business rules run when records are displayed, inserted, updated, deleted or queried.
- Script includes hold reusable server-side code that other scripts can call.
- Scheduled jobs run scripts at set times.
- Scripts - Background lets administrators run a server-side script once, for example to fix data. Use it with care: it acts directly on the instance.
Good practice
- Use UI policies instead of client scripts where possible, and flows instead of scripts for processes.
- Keep server calls from client scripts to a minimum, because they slow down forms.
- Test scripts on a sub-production instance, never directly in production.
Step 2 · Do
Choose the right script
Acme's requirements need a little code. Decide where each script runs and which type to use. This is a practice environment of our own design, not the ServiceNow product. Complete the tasks in the task list.
Step 3 · Check
Exam-style questions
Select an answer and check it. Every answer includes an explanation.