Client Side Scripting Flashcards

1
Q

What are the two types of scripts found in ServiceNow?

A

Client Side & Server Side

———————————————————————
📁 Client Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Where do client scripts execute?

A

Within a user’s browser

———————————————————————
📁 Client Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When do client scripts execute?

A

When forms are loaded, changed, or submitted

———————————————————————
📁 Client Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the main 2 reasons an onLoad client script would be used?

A

To manipulate a form’s appearance
or manipulate a form’s content

———————————————————————
📁 Client Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

When does an onLoad script execute?

A

When a form is loaded.

———————————————————————
📁 Client Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When does an onChange script execute?

A

When a particular field’s value changes.

———————————————————————
📁 Client Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why would you use an onChange client script?

A

An onChange client script will allow you to monitor fields that contain values of interest and modify the values or attributes of another field based on changes to your field of interest.

———————————————————————
📁 Client Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When do onSubmit scripts execute?

A

When a form is submitted

———————————————————————
📁 Client Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Why would you use an onSubmit client script?

A

Validate field values

———————————————————————
📁 Client Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What type of API is GlideForm?

A

Client-side

———————————————————————
📁 Client Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the GlideForm API do?

A

Provides methods for managing form and form fields.

Some Examples:
- Retrieve a field value on a form
- Hide a field
- Make a field read-only
- Write a message on a form or a field
- Add fields to a choice list
- Remove fields from a choice list

———————————————————————
📁 Client Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What syntax is used when implementing methods from the GlideForm API?

A

g_form.<method></method>

———————————————————————
📁 Client Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What types of scripts support the use of the g_form object?

A

Client side scripts

———————————————————————
📁 Client Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Can you list off some of the methods commonly used with the g_form object?

A
  • getValue()
  • addOption()
  • clearOptions()
  • addInfoMessage()
  • addErrorMessage()
  • showFieldMessage()
  • clearMessages()
  • getSections()
  • getSectionName()

———————————————————————
📁 Client Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does the GlideUser API do?

A

Provides methods and non-method properties for finding information about the currently logged in user and their roles.

———————————————————————
📁 Client Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What syntax is used when implementing methods or accessing non-method properties from the GlideUser API?

A

g_user.<method></method>

———————————————————————
📁 Client Side Scripting Developer Documentation

17
Q

What information would the following code display in a brand new ServiceNow developer instance?

g_user.firstName

A

System

———————————————————————
📁 Client Side Scripting Developer Documentation

18
Q

What information would the following code display in a brand new ServiceNow developer instance?

g_user.lastName

A

Administrator

———————————————————————
📁 Client Side Scripting Developer Documentation

19
Q

What information would the following code display in a brand new ServiceNow developer instance?

g_user.userName

A

admin

———————————————————————
📁 Client Side Scripting Developer Documentation

20
Q

What information would the following code display in a brand new ServiceNow developer instance?

g_user.userID

A

This returns the sys_id for the individual

———————————————————————
📁 Client Side Scripting Developer Documentation

21
Q

What types of scripts support the use of the g_user object?

A

Client side scripts

———————————————————————
📁 Client Side Scripting Developer Documentation

22
Q

Can you list off some of the methods most commonly used with the g_user object?

A
  • hasRole()
  • hasRoleExactly()
  • getFullName()

———————————————————————
📁 Client Side Scripting Developer Documentation

23
Q

What are the similarities between client side scripts and UI policies?

&

What are the differences between client side scripts and UI policies?

A

They are both client side logic that governs form and form field behavior.

&

UI policies don’t require any scripting

———————————————————————
📁 Client Side Scripting Developer Documentation

24
Q

What are UI policy actions?

A

Client side logic within a UI policy, used to set three field attributes:

  • Mandatory
  • Visible
  • Read Only

———————————————————————
📁 Client Side Scripting Developer Documentation

25
Q

What do UI Policy Scripts do?

A

They use the client-side API to execute script logic based on whether the UI Policy condition tests true or false

———————————————————————
📁 Client Side Scripting Developer Documentation

26
Q

Why would you use a UI Policy Script?

A

To create complex conditional checks or to take actions other than setting field attributes (mandatory, read-only, or visible)

———————————————————————
📁 Client Side Scripting Developer Documentation

27
Q

Which runs first, UI Policies or Client Scripts?

&

If there is a conflict of logic, which of the two is applied?

A

Client Scripts execute first

&

UI Policy logic applies in this scenario

———————————————————————
📁 Client Side Scripting Developer Documentation

28
Q

Which of these classes are part of the ServiceNow client-side API?
More than one may be correct

  • GlideSystem (gs)
  • GlideUser (g_user)
  • GlideDateTime
  • GlideDate
  • GlideForm (g_form)
A
  • GlideUser (g_user)
  • GlideForm(g_form)

———————————————————————
📁 Client Side Scripting Developer Documentation

29
Q

True or False?

A single client script can execute its script logic when a user loads a record into a form AND when a user saves/submits/updates a form

A

False

A single client script can be either onLoad OR onSubmit but cannot be both. The Type field determines whether a Client Script is an onLoad or an onSubmit client script

———————————————————————
📁 Client Side Scripting Developer Documentation

30
Q

What are client scripts used for?

A

To manage forms and form fields

———————————————————————
📁 Client Side Scripting Developer Documentation

31
Q

What are the three types of client scripts?

A

onLoad, onChange, and onSubmit

———————————————————————
📁 Client Side Scripting Developer Documentation

32
Q

Why should onLoad client scripts be used sparingly?

A

They impact form load times.

———————————————————————
📁 Client Side Scripting Developer Documentation

33
Q

What are the 5 parameters passed to the onChange() client script automatically by ServiceNow?

A

control, oldValue, newValue, isLoading, isTemplate

———————————————————————
📁 Client Side Scripting Developer Documentation

34
Q

What does the automatically passed “control” parameter reference within the context of an onChange client script?

A

The control parameter contains information to reference the field for which the client script is written.

———————————————————————
📁 Client Side Scripting Developer Documentation

35
Q

What does the automatically passed “oldValue” parameter reference within the context of an onChange client script?

A

The oldValue parameter contains the value that was present in the field on form load - before the change.

———————————————————————
📁 Client Side Scripting Developer Documentation

36
Q

What does the automatically passed “newValue” parameter reference within the context of an onChange client script?

A

The newValue parameter contains the value that is now in the field after the change has taken place.

———————————————————————
📁 Client Side Scripting Developer Documentation

37
Q

What does the automatically passed “isLoading” parameter reference within the context of an onChange client script?

A

The isLoading parameter contains a boolean value indicating whether change came from a form load or not.

———————————————————————
📁 Client Side Scripting Developer Documentation

38
Q

What does the automatically passed “isTemplate” parameter reference within the context of an onChange client script?

A

The isTemplate parameter contains a boolean value indicating whether the change occurred due to population of the field by a template.

———————————————————————
📁 Client Side Scripting Developer Documentation