What is GlideQuery

So this is a new thing that may change how code is written for some.

Let me show you an example of the code and output. Then I'll write my thoughts.

var testGlideQuery = new GlideQuery('sys_user')
.where('active', true)
.select('first_name', 'last_name', 'active')
.toArray(100);
gs.info('testGlideQuery: ' + JSON.stringify(testGlideQuery,'',' '));

/*
*** Script: testGlideQuery: [
{
"first_name": "a",
"last_name": "b",
"active": true,
"sys_id": "9033c10d2f674c10bd54d5f62799b666"
},
{
"first_name": "Aada",
"last_name": "Keranen",
"active": true,
"sys_id": "15a849d32fd34810bd54d5f62799b6be"
},
...
*/

So, yea. That's interesting. Before you go and look if you can use this in your instance, you probably don't have it yet. To get it, enable the SAM and SAAS plugins.

The methods are exposed and is written in a interesting way. I suggest you check it out.

This brings up the big question, is GlideRecord going away? No. I don't think so. This seems to be just a wrapper to allow chain-able calls to query the data. Maybe as the Now Experience comes up this will be used more in that but I don't think so. I think this is just a wrapper some team made to make their code look one way.

In any case, I wanted to write this down so if anyone looks for it something comes up, because as of now, it's not written down anywhere.

Comments

crash180 commented on Apr 29, 2020

Interesting the things you can find when you dig a little bit. I have not heard of GlideQuery either

nikhilkumarsrs commented on May 5, 2020

Hi Jace, It says
Evaluator: org.mozilla.javascript.EcmaError: "GlideQuery" is not defined.
Caused by error in script at line

jacebenson commented on May 6, 2020

@nikhilkumarsrs You'll need to enable the SAM Pro plugins to use this it seems

nikhilkumarsrs commented on May 6, 2020

@jacebenson Hi Jace, SAM pro plugin is already active and still same error.

jacebenson commented on May 6, 2020

I must have some more things on... com.sn_glidequery is what it says it's a part of;

image

jacebenson commented on May 6, 2020

Maybe it's installed as part of this, but this isn't on the production instance I have access to.
image

I know I have this on all the environments it exists;
image

sn_sam_saa

nthumma commented on May 25, 2020

Nice article Jace!