DEV Community

Cover image for The Glides: Understanding ServiceNow Glide APIs-The Difference between GlideAjax vs GlideRecord
Sophia Semga
Sophia Semga

Posted on • Updated on

The Glides: Understanding ServiceNow Glide APIs-The Difference between GlideAjax vs GlideRecord

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:

  1. Define a script include or scripted REST API with the desired logic for asynchronous invocation. Image description
  2. 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. Image description

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. Image description
  • addQuery(): Adds additional conditions to the query. Image description
  • get(): Retrieves a single record based on current query conditions. Image description
  • next(): Moves the GlideRecord cursor to the next record in the result set. Image description
  • insert(): Adds a new record to the database. Image description
  • update(): Modifies the current record. Image description
  • deleteRecord(): Removes the current record. Image description

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:

https://developer.servicenow.com/dev.do#!/learn/learning-plans/tokyo/new_to_servicenow/app_store_learnv2_scripting_tokyo_introduction_to_servicenow_scripting

https://developer.servicenow.com/dev.do#!/learn/courses/tokyo/app_store_learnv2_scripting_tokyo_scripting_in_servicenow

•Learn More About ServiceNow GlideAjax Here:

https://docs.servicenow.com/bundle/washingtondc-api-reference/page/app-store/dev_portal/API_reference/GlideAjax/concept/c_GlideAjaxAPI.html

https://docs.servicenow.com/bundle/washingtondc-application-development/page/script/ajax/topic/p_AJAX.html

•Learn More About ServiceNow GlideRecord Here:

https://docs.servicenow.com/bundle/washingtondc-api-reference/page/app-store/dev_portal/API_reference/GlideRecord/concept/c_GlideRecordAPI.html

##TheWorldWorksWithServiceNow🌏

Top comments (0)