GlideQuery Perks, Part 2: JavaScript Not Java
Another point I made in Part 0 of this series was that GlideRecord is a Java object and its various methods return Java types and more Java objects, so it doesn’t behave like native JavaScript. In contrast, though GlideQuery uses GlideRecord to perform database operations in its private implementation, its public interface is written entirely in JavaScript and was intentionally designed to behave like JavaScript.
GlideQuery Perks, Part 1: Unambiguous Boolean Logic
I published Part 0 and Part 0.5 of this series so long ago you probably thought I forgot about it, but this is a favorite topic of mine so I couldn’t leave it unfinished. 😅 If you haven’t read the first part, I highly recommend catching up before reading this.
One of the problems I mentioned in Part 0 is that GlideRecord is squirrelly when it comes to precedence of logical AND and OR. GlideQuery avoids this issue by disallowing ambiguous boolean logic.
Hardcoded Values Locator
I don’t know about your ServiceNow environment, but we’ve got a lot of technical debt built up in ours in the form of hardcoded values (users, groups, etc.) in legacy Workflows and Flow Designer Flows.
Python Script for Downloading Attachments
I’ve been exporting a lot of data from my ServiceNow instance lately for archival purposes (IYKYK) and one of the challenges I’ve encountered is properly preserving attachments.
The GQ Script Include
The GlideQuery helper functions you never knew you needed
I wonder how many ServiceNow developers know the GQ script include exists. Maybe you’ve heard of GlideQuery, but GQ is a bit of an undocumented feature.
BetterGetter
In keeping with my series about GlideQuery, I’d like to share a tool Dan and I made that can slightly improve the experience when you’d prefer to use GlideQuery but have no choice but to use GlideRecord.
Scripted Due Dates in the Ask For Approval Action
Something in Flow Designer that has always bothered me is that I’ve been unable to get scripted due dates to work in the Ask For Approval action. If you’re unfamiliar, due dates provide the ability to specify how long the flow should wait for approval, as well as what action should be taken on the approval when the specified due date arrives. This prevents a flow from waiting endlessly for an approval response.
GlideQuery Perks, Part 0.5: Resources
Before I start my GlideQuery series proper, I’d be remiss if I didn’t take two steps back and recognize all the great content already out there on the topic. I certainly didn’t discover all the benefits of GlideQuery myself, though I do have direct experience with most of them. This article will be a complete rundown on every publicly available resource I can find.
Friends Don’t Let Friends Use GlideAjax
I used to hate writing GlideAjax Script Includes, but I haven’t written one in probably five years. How have I avoided it? Easy! Let me show you how to hit the Table API in a Client Script using vanilla JavaScript.
GlideQuery Perks, Part 0: What’s wrong with GlideRecord?
When I first encountered GlideQuery, for a brief moment I naively assumed it was a complete modern replacement for GlideRecord and I got really excited. I was quickly disappointed when I learned it’s just a wrapper for GlideRecord. As such, I thought it must have all the same drawbacks and limitations, and for a while I admit I was an unbeliever and a naysayer. But, as I learned more, I realized GlideQuery is one of the best things that ever happened to ServiceNow. I’ve been using it exclusively for nearly two years and I hope through this new series of articles I can convince you to switch if you haven’t.
GlideQuery: Selecting All Fields
I love how GlideQuery’s select method takes a list of column names and returns a Stream of records with only those columns. Since it uses GlideRecord under the hood, I’m not sure we get much performance gain from it, but it makes working with the resulting objects so much more pleasant, having exactly and only the columns you need in a given context. But what can you do if you really need every column for a given record?