0% found this document useful (0 votes)
9 views8 pages

Client Side Scripting ServiceNow

Client-side scripting in ServiceNow enhances user interaction with forms through JavaScript code known as Client Scripts, which can manipulate fields and validate inputs. There are various types of Client Scripts including onLoad, onChange, onSubmit, and onCellEdit, each serving different purposes. Best practices for using these scripts include minimizing their use for performance, avoiding synchronous GlideAjax calls, and thoroughly testing scripts before deployment.

Uploaded by

capturedshots23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views8 pages

Client Side Scripting ServiceNow

Client-side scripting in ServiceNow enhances user interaction with forms through JavaScript code known as Client Scripts, which can manipulate fields and validate inputs. There are various types of Client Scripts including onLoad, onChange, onSubmit, and onCellEdit, each serving different purposes. Best practices for using these scripts include minimizing their use for performance, avoiding synchronous GlideAjax calls, and thoroughly testing scripts before deployment.

Uploaded by

capturedshots23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Client-Side Scripting in

ServiceNow
An Overview of Client Scripts and
Their Functionality
Introduction
• Client-side scripting in ServiceNow allows real-
time interaction with form fields, enhancing
user experience and enforcing business logic.
What is a Client Script?
• A Client Script is a piece of JavaScript code
that runs on the client side (browser) to
manipulate form fields, validate inputs, and
trigger actions.
Types of Client Scripts
• - onLoad: Executes when a form is loaded
• - onChange: Runs when a field value changes
• - onSubmit: Validates before form submission
• - onCellEdit: Triggers when a cell value is
edited in a list
GlideForm (g_form)
• g_form is used to interact with form fields in
ServiceNow.
• Common Methods:
• - g_form.getValue('field_name')
• - g_form.setValue('field_name', 'value')
• - g_form.addErrorMessage('Error message')
GlideUser (g_user)
• g_user provides information about the logged-
in user.
• Common Methods:
• - g_user.hasRole('role_name')
• - g_user.userID
• - g_user.userName
GlideAjax
• GlideAjax is used to call server-side scripts
from the client-side.
• Example:
• var ga = new GlideAjax('ScriptIncludeName');
• ga.addParam('sysparm_name',
'methodName');
• ga.getXMLAnswer(callbackFunction);
Best Practices
• - Use minimal client scripts to improve
performance.
• - Avoid synchronous GlideAjax calls.
• - Reuse Script Includes for server-side logic.
• - Test scripts thoroughly before deploying.

You might also like