Have you ever wanted to get a quick GlideRecord Query for a list you’re looking at? I’ve wanted to do that many times. Sometimes it’s because I’m writing a business rule and sometimes I’ve got to run a background script to update some values. I ran into this yesterday when I was working on a scripted web service with about 50 inputs and was making a second related web service that needed the same inputs as the first. I ended up writing a background script to do a simple query of the first web service inputs and insert a copy of each one for the new web service.
Using this little helper I put together the other day saved me some time and hassle of tracking down the table names and filters to get the right query. It’s a simple little script that makes life as an admin just a little bit easier.
To set it up in your instance go to System UI -> UI Context Menus and open a new record. The other values should be as follows:
Menu: List Header
Name: Get GlideRecord Query
Now that you’ve got this, from any List you can right-click on the header and the bottom option will be “Get GlideRecord Query” and you can copy the resulting code. It’s nothing complicated, but can still save a bit of time.
The key to making this work is the g_list object that has the details for the list that you’re on. It’s documented fairly well on the ServiceNow Wiki and if you haven’t seen it before I’d recommend glancing at what options are available.