client-scripts

Implement and optimize ServiceNow client scripts for browser-based form behavior.

34|13|Updated Feb 6, 2026
One-click install
npx skills add https://github.com/Happy-Technologies-LLC/happy-servicenow-skills --skill client-scripts-happy-technologies-llc
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: client-scripts
Source: https://github.com/Happy-Technologies-LLC/happy-servicenow-skills/tree/main/skills/development/client-scripts
Command: npx skills add https://github.com/Happy-Technologies-LLC/happy-servicenow-skills --skill client-scripts-happy-technologies-llc

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide helps developers implement and optimize ServiceNow client scripts to control browser-based form behavior and deliver responsive user experiences.

Core Features & Use Cases

  • Support for client script types: onLoad, onChange, onSubmit, and onCellEdit
  • Practical guidance on g_form API usage, reference handling, and scratchpad data flows
  • GlideAjax-based server calls for asynchronous data exchange and server-side validation
  • Performance-focused patterns, debugging tips, and mobile/service portal considerations
  • Real-world examples and best practices for robust form behavior

Quick Start

Install the client-scripts skill in your ServiceNow development environment and begin creating onLoad, onChange, onSubmit, and onCellEdit examples.

Frequently Asked Questions about client-scripts

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write ServiceNow client scripts to control form behavior?

ServiceNow client scripts control browser-based form behavior by implementing onLoad, onChange, onSubmit, and onCellEdit logic. You use the g_form API for field interactions and GlideAjax for asynchronous server-side data exchange to deliver responsive user experiences.

What is the difference between onLoad and onChange client scripts in ServiceNow?

onLoad client scripts execute when a form loads into the browser, useful for initial field setup. onChange client scripts trigger when a user modifies a specific field value, enabling dynamic form validation and dependent field updates as users interact.

How do I use GlideAjax in a ServiceNow client script?

GlideAjax enables asynchronous server calls from client scripts to retrieve or validate server-side data without reloading the form. You instantiate the GlideAjax object, specify the server-side script include name, add parameters, and use a callback function to process the response.

Can I use g_form API calls in ServiceNow service portal and mobile interfaces?

g_form API usage requires specific considerations for ServiceNow service portal and mobile contexts. Not all g_form methods are fully supported across mobile and desktop interfaces, so you must verify compatibility and apply mobile-specific patterns to ensure safe, scalable configurations.

What are the best practices for debugging and optimizing ServiceNow client script performance?

Optimizing ServiceNow client script performance involves minimizing server calls, using scratchpad data flows to reduce redundant queries, and applying debugging best practices. You should carefully scope onChange scripts to necessary fields and avoid synchronous GlideAjax calls to maintain form responsiveness.

Why is my ServiceNow onSubmit client script not preventing form submission?

onSubmit client scripts must return a boolean value to control form submission. If the script returns true, submission proceeds, while returning false stops it. Ensure your validation logic explicitly returns false and uses GlideAjax callbacks correctly to handle asynchronous server-side validation.