a shot of dev knowledge

RELATED TAGS

How to get and set field values in ServiceNow

Overview of Glide class

Glide class works hand in hand with ServiceNow to use databases and perform operations on the UI objects and pages.

Glide mainly shares Javascript APIs to deal with front-end and back-end, resulting in a highly interactive and user-friendly application.

Glide sub-classes

Glide classes are divided into two further categories: client-side and server-side.

Let’s take a closer look at these.

Client-side classes include:

  • GlideAjax
  • GlideDialogWindow
  • GlideForm
  • GlideList2
  • GlideMenu
  • GlideUser

Server-side classes include:

  • GlideRecord
  • GlideElement
  • GlideSystem
  • GlideAggregate
  • GlideDateTime

Set field values

To set a value in the field, setValue(name, value) comes into play. This function can be used from any of the sub-classes.

GlideClassElement.setValue(name, "value");
Setting a value in glide sub object
  • GlideClassElement is the glide class sub-element that we need to set for GlideRecord, GlideForm, etc.
  • name is the title of the field that we want to update. The data type of this field is string.
  • value is the new value that we want to set. The data type of this field is object.
  • The return type of this function is void.

Get field values

To get a value, we use the getValue(String name) function. It returns a string containing the value of the field.

getValue(String name) returns null if the field is empty or does not exist.

GlideClassElement.getValue(name);
Getting a value from glide sub object
  • GlideClassElement is the glide class sub-element that we need to get.
  • name is the title of the field that we want to update. The data type of this field is string.

RELATED TAGS

RELATED COURSES

View all Courses

Keep Exploring