Sie sind auf Seite 1von 5

June 27, 2017

ServiceNow Documentation

This PDF was created from content on docs.servicenow.com. The web site is updated frequently.
For the most current ServiceNow product documentation, go to docs.servicenow.com.
You can find the most up-to-date technical documentation on the ServiceNow web site at:
http://docs.servicenow.com
The ServiceNow site also provides the latest product updates.
If you have comments about this documentation, submit your feedback to:
docfeedback@servicenow.com

Company Headquarters
2225 Lawson Lane
Santa Clara, CA 95054
United States
(408)501-8550

2017 ServiceNow. All rights reserved.


Terms of Use Privacy Statement
ServiceNow | Client scripts

Client scripts

Clients scripts allow the system to run JavaScript on the client (web browser) when client-
based events occur such as when a form loads, after form submission, or when a field
changes value.

Client script types


The system can run client scripts for these client-based events.

Type and required function name Description


onLoad() An onLoad() client script runs when the system
first renders the form and before users can enter
data. Typically, onLoad() client scripts perform
client-side-manipulation of the current form or
set default record values.
onSubmit() An onSubmit() client script runs when a form is
submitted. Typically, onSubmit() scripts validate
things on the form and ensure that the
submission makes sense. An onSubmit() client
script can cancel form submission by returning a
value of false.
onChange() An onChange() client script runs when a
particular field value changes on the form. The
onChange() client script must specify these
parameters.

control: the DHTML widget whose value


changed.
oldValue: the value the widget had when the
record was loaded.
newValue: the value the widget has after the
change.
isLoading: identifies whether the change occurs
as part of a form load.
isTemplate: identifies whether the change
occurs as part of a template load.

onCellEdit() An onCellEdit() client script runs when the list


editor changes a cell value. The onCellEdit() client
script must specify these parameters.

sysIDs: an array of the sys_ids for all items


being edited.
table: the table of the items being edited.
oldValues: the old values of the cells being
edited.
newValue: the new value for the cells being
edited.
callback: a callback that continues the
execution of any other related cell edit scripts. If
true is passed as a parameter, the other scripts
are executed or the change is committed if

June 27, 2017 2017 ServiceNow. All rights reserved. 3


ServiceNow | Client scripts

Type and required function name Description


there are no more scripts. If false is passed as a
parameter, any further scripts are not executed
and the change is not committed.

Note: onCellEdit() client scripts do not


apply to dashboard list widgets.

Where client scripts run


With the exception of onCellEdit() client scripts, client scripts only apply to forms. Client
scripts are not compatible with search pages. If you create a client script to control field
values on a form, you must use one of these other methods to control field values when on a
list.

Create an access control to restrict who can edit field values.


Create a business rule to validate content.
Create a data policy to validate content.
Create an onCellEdit() client script to validate content.
Disable list editing for the table.

Introduction to client scripts, script types, APIs, and good


practices

Client API
The client-side Glide API provides classes and methods that you can use in client-side
scripts.
UI scripts

UI scripts provide a way to package client-side JavaScript into a reusable form, similar to
how script includes store server-side JavaScript. Administrators can create UI scripts and
run them from client scripts and other client-side script objects and from HTML code.
Client script best practices

June 27, 2017 2017 ServiceNow. All rights reserved. 4


ServiceNow | Client scripts

Well-designed client scripts can reduce the amount of time it takes users to complete a
form.
Create a catalog client script

Follow this procedure to create a catalog client script.


AJAX

AJAX (asynchronous JavaScript and XML) is a group of interrelated, client-side


development techniques used to create asynchronous Web applications.
Jelly tags

This is a list of Jelly tags and Glide tags.

June 27, 2017 2017 ServiceNow. All rights reserved. 5

Das könnte Ihnen auch gefallen