Peter Bell

Peter Bell

9 minute read

Stream Processing (Part 2) The second half of our Stream introduction. If you haven’t read the first half, I recommend you do so before going forward. In this post, we cover: reduce flatMap and nested queries Using chunk to improve nested query performance Creating custom Streams reduce Conceptually, a Stream can be viewed as a collection containing the results of a query. However, sometimes we want to boil down (or reduce) this collection of records into a single value.

Peter Bell

7 minute read

Stream Processing (Part 1) In this series, I’ve mentioned the Stream class, which is the way GlideQuery users process multiple records and groups returned by the select method. Stream is similar to Java’s Stream class and C#’s IEnumerable interface. In all the examples so far, I’ve only used Stream’s forEach method, as that’s one of the most common Stream methods available. There are, however, other powerful Stream methods available that can enhance your code.

Peter Bell

4 minute read

Dotwalking and Flags Similar to GlideRecord, GlideQuery supports dotwalking, both when using select and where. It dramatically simplifies filtering and reading in fields referenced by the current table instead of executing another GlideQuery. Dotwalking is presumed in the Now platform and should be reasonably familiar to most GlideRecord developers. Dotwalking Just like GlideRecord, GlideQuery supports filtering using dotwalking: var tokyoEmployee = new GlideQuery(‘sys_user’) .where(‘company.city’, ‘Tokyo’) .selectOne(‘name’) .get(); When dotwalking, GlideQuery performs the same set of validation checks as regular field names.

Peter Bell

3 minute read

Advanced Aggregate Queries As I mentioned in my previous article, GlideQuery supports simple and complex functionality. The simple aggregate functions sum, avg, max, and min are easy to use and have little syntax. However, they have two significant limitations: They don’t support grouping They support only one aggregation per query Grouping What if I want to count the number of users in each city? new GlideQuery(‘sys_user’) .aggregate(‘count’) .

Peter Bell

3 minute read

Continuing on the journey to explore the GlideQuery Series is Part 3! Time to take out a death star. Simple Aggregate Queries Sometimes we need aggregate queries (MAX, COUNT, etc.). Fortunately, GlideQuery supports these, while also making them easier to use than ever. For example, compare var usersGa = new GlideAggregate(‘sys_user’); usersGa.addAggregate(‘COUNT’); usersGa.query(); usersGa.next(); var userCount = parseInt(usersGa.getAggregate(‘COUNT’)); with var userCount = new GlideQuery(‘sys_user’).count(); Much easier to read!

Peter Bell Andrew Barnes

4 minute read

Inserting, Updating, and Deleting in GlideQuery! Part 2 of the GlideQuery Series. Read Part 1 to catch up. This is the second in a series of blog posts showing practical examples and patterns using GlideQuery. I believe one of the quickest ways to learn is by diving straight into examples. We’ll start with simple read queries and move on to more advanced topics with each post. Let’s begin! Inserting new GlideQuery(‘task’) .

Peter Bell

5 minute read

My name is Peter Bell. I have been a software developer and tester for the past 16 years for various Seattle area companies. I enjoy cycling, rooting for the Seattle Mariners (not easy), and good beer. My passion for API design and functional programming led me to develop GlideQuery, which we initially used in the ITAM (IT Asset Management) team at ServiceNow. We have expanded its use, both within ServiceNow and to our customers.