The Glides: Understanding ServiceNow Glide APIs-The Difference between GlideAjax vs GlideRecord
Sophia Semga
Posted on March 20, 2024
In the realm of ServiceNow scripting, terms like Glide Ajax, Glide Record, and Glide Form often appear, but what do they actually mean?? How do they relate to scripting syntax, and why do they sound so similar?
In this blog, we will glide through the explanation of these API functions, addressing these questions except for the curious resemblance in names.đ
To begin, it's crucial to understand that Glide Record and Glide Ajax are distinct APIs with separate functionalities, catering to different scripting aspects within ServiceNow.
Now that weâve got that introduction out of the way, letâs dive in.âŹď¸
To understand and differentiate between the two sets of APIs, we need to backtrack to the beginning of ServiceNow. In the early stages of ServiceNow development, the term "Glide" originated from the foundational technology framework of the ServiceNow platform. This framework incorporates various APIs, libraries, and technologies that aid developers in building and customizing applications. Given that ServiceNow heavily relies on JavaScript for client-side and server-side scripting, the Glide APIs are JavaScript-based, making it familiar and accessible for developers.
Glide Record, Glide Ajax, and other Glide APIs were purpose-built by ServiceNow to streamline interactions within the platform, enhancing efficiency and customization capabilities for developers.
Understanding Glide Ajax
Glide Ajax operates as a client-side API, enabling asynchronous calls to server-side scripts (such as script includes and business rules) from client-side scripts (like UI policies and Catalog UI policies). This asynchronous communication ensures that server-side actions, such as querying databases, occur without disturbing website performance, ultimately enhancing the user experience.
Unlike Glide Record, Glide Ajax does not have its own set of APIs but rather serves as a channel between client-side JavaScript and server-side scripts, allowing seamless integration of server-side functionality without page refreshes. The core method in Glide Ajax, getXMLWait()
, facilitates sending requests to server-side script includes or scripted REST APIs, and awaiting responses for further client-side processing.
Here's a basic example illustrating Glide Ajax usage:
- Define a script include or scripted REST API with the desired logic for asynchronous invocation.
- Create a client-side script (e.g., UI policy or UI action) utilizing Glide Ajax to call the server-side script and handle the response.
While Glide Ajax offers a limited range of methods, its specialized role in facilitating asynchronous client-server communication within the ServiceNow platform is invaluable.
Exploring Glide Record
On the server side, Glide Record shines as an essential API for database operations, eliminating the need for direct SQL queries. It empowers developers to conduct queries, updates, and deletions of records efficiently within ServiceNow scripts, such as script includes and business rules.
Glide Record provides a strong set of APIs, including:
-
query()
: Executes query records based on specified conditions. -
addQuery()
: Adds additional conditions to the query. -
get()
: Retrieves a single record based on current query conditions. -
next()
: Moves the GlideRecord cursor to the next record in the result set. -
insert()
: Adds a new record to the database. -
update()
: Modifies the current record. -
deleteRecord()
: Removes the current record.
These APIs, combined with specific conditions and parameters, empower developers to manipulate records and ServiceNow tables effectively, enhancing workflow automation and data management.
In conclusion, while Glide Record and Glide Ajax fulfill distinct roles within the ServiceNow ecosystem, they are essential components contributing to platform functionality. Glide Record streamlines server-side database interactions, while Glide Ajax facilitates efficient client-server communication, collectively enhancing user experiences and productivity within ServiceNow environments.
â˘Learn More About ServiceNow Scripting Here:
â˘Learn More About ServiceNow GlideAjax Here:
â˘Learn More About ServiceNow GlideRecord Here:
##TheWorldWorksWithServiceNowđ
Posted on March 20, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
March 20, 2024