logo

NJP

Share App - Get GlideRecord Query from List

Import · May 10, 2016 · article

A while back I was working on a project where I ended up having to write some GlideRecord queries based on quite a few different tables and parameters. I was using syntax editor macros along with the find and replace feature in the syntax editor, but it seemed to me like it should be easier than.

I started thinking about what I really wanted, and what I decided was that I wanted a way to generate a GlideRecord query from a list that contained the table name, the encoded query string, the sort field, and allow me to set the variable name of the GlideRecord object. Once I had those goals, the execution was actually pretty straightforward, so I built it out and uploaded it to share.

Get GlideRecord Query from List

Here's a screenshot demo of how it works after you've uploaded the update set into your instance.

First you can go to any list and add some queries to the filter:

f7ec25aab5.png

Then run the query and click the Get Query list banner ui action and you'll get a prompt to name you GlideRecord object variable.

6275146d65.png

Name it (something other than gr) and hit ok, and you'll get another popup with your generated GlideRecord code.

6df0851be5.png

Now hit CTRL+C and paste that into your script editor of choice:

db469d27c5.png

That's it! Just a simple way to easily generate a GlideRecord query from a list of records to use wherever you'd like.

View original source

https://www.servicenow.com/community/developer-blog/share-app-get-gliderecord-query-from-list/ba-p/2284381