1

Glide Classes & Script Execution Engine

ServiceNow allows developers a great way to effectively script using its two major tools. Glide classes (ServiceNow toolkit) and the script execution engine (Engine to run your code). This topic focuses on how both of these work, execute and help you while scripting for both client- and server-side. 

What are Glide Classes? 

ServiceNow is a Java-based framework that is known as Glide. Glide classes in ServiceNow are pre-built JavaScript APIs that offer access to platform features. Rather than writing code from scratch, you can use these classes to query tables, access user details, work with them and manipulate forms. 

There are different Glide classes as per their usage on the client side and server side. 

Server-Side Glide Classes Client-Side Glide Classes
GlideRecord GlideForm (g_form)
GlideSystem (gs) GlideUser (g_user)
GlideAggregate GlideAjax
GlideDateTime GlideList (g_list)
GlideElement GlideModal / GlideDialogWindow
GlideFilter
GlideSysAttachment
RESTMessageV2 / SOAPMessageV2

Using Glide Classes

Best ways to use Glide classes are: 

  • Use GlideAggregate instead of looping with GlideRecord when you want to total or count. 
  • Ensure that client-side records are minimal, as they are synchronous and can slow the forms. Instead, you can use GlideAjax. 
  • Always add small query conditions so there are fewer records to fetch. 
  • Use gs.info(), gs.warn(), and gs.error() for logging and avoid leaving debug logs in production. 

What is the script execution engine? 

The script execution engine is a ServiceNow component that reads and runs your scripts. 

Server-side scripting in ServiceNow is powered by Mozilla Rhino, which acts as an open-source engine built on Java to compile JavaScript into Java classes to execute on the Java Virtual Machine. 

Client-side scripting is directly executed within the web browser using a native JavaScript engine. It works and manages Client scripts and UI actions for a better user experience. 

What’s Next?

After understanding how to write code and the different types of scripting, one important thing is to edit that code. In the next topic, we will be covering the Syntax Editor and Macros in ServiceNow. 

Next Topic

Need more support?

Get a head start with our FREE study notes!

Learn more and get all the answers you need at zero cost. Improve your skills using our detailed notes prepared by industry experts to help you excel.