Design a site like this with WordPress.com
Get started

GlideQuery NOT GlideRecord

Hello guys,

Today I was going through some blogs from @jacebenson and I found a really interesting thing called “GlideQuery”. not GlideRecord

image

YAA!!!

I decided to explore this. There were no docs no session nothing. Literally nothing. I messaged Jace at discord to know more. I had a quick chat and started exploring. I found it really helpful as in it gives me the control which I always wanted to have while using GlideRecord. I mean it is just wrapper around GlideRecord but still. 

I have recorded one video. Code that I showed in the video is below:

For Plugin Activation:

var plugins = [];
plugins.push('com.sn_glidequery');
var main = new GlideMultiPluginManagerWorker();
main.setPluginIds(plugins);
main.setProgressName("Plugin Installer");
main.setBackground(true);
main.start(); 

Sample 1:

var gd=new GlideQuery('sys_user')
    .whereNull('last_name')
  .select('first_name','email')
  .forEach(function(user){
  gs.print(user);
  });

Sample 2:

var gd=new GlideQuery('sys_user')
    .where('user_name',"STARTSWITH",'a')
  .select('first_name','email')
  .forEach(function(user){
  gs.print(JSON.stringify(user));
  });

Sample 3:

 var gd = new GlideQuery('sys_user')
      .getBy({
          first_name: 'Fred',
          last_name: 'Luddy'
      }, ['first_name', 'last_name', 'city', 'active']) 
      .orElse({
          first_name: 'Nobody',
          last_name: 'Found',
          city: 'Nowhere',
          active: false
     });
gs.print(JSON.stringify(gd));

Sample 4:

var gd = new GlideQuery('incident')
.limit(20)
.select('number')
.forEach(function(user){
  gs.print(JSON.stringify(user));
  });

Sample 5:

var user = new GlideQuery('sys_user')
     .insertOrUpdate({
          first_name: 'Debasis',
          last_name: 'Majhi'
      })
      .orElse(null);

Links:

Jace Benson Article

In case you need any help, please do connect with me. It will be my pleasure to help you.

 Happy Learning Guys!!!

—–>Dhruv Gupta

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: