Can someone help me to use the query result?

Betzaida Garci1
Kilo Contributor

Hi Everyone!

So, I have this script I've been trying to fix this to use the result of the query but it prints the whole table.

I want to use only que result of the query and print it, but idk if I should use another glideRecord or maybe a getQuery or something like that.

(function runMailScript(template, current, email, email_action, event) {
var tb = new GlideRecord ('sys_store_app');
tb.addQuery('sys_mod_countISNOTEMPTY');
tb.query(); // execute query

while (tb.next()){
template.print('Name: ' + tb.name + '\n');
}

})(template, current, email, email_action, event);

3 REPLIES 3

Community Alums
Not applicable

Hi, 

Normally sys_mod_count wouldn't ever be empty. Are you meaning to search for it when it equals 0? 

Mike

Hi!

I want to display all the apps that need to be updated, but I'm not sure on how to do it

Community Alums
Not applicable

Hi, 

This will scan the entire table and compare the versions: 

var grStoreApp = new GlideRecord ('sys_store_app');
grStoreApp.query(); 
while(grStoreApp.next()){
    if(grStoreApp.version != grStoreApp.latest_version && grStoreApp.version<grStoreApp.latest_version){
        gs.info(grStoreApp.name+' v:'+grStoreApp.version+' latest:'+grStoreApp.latest_version)
    }
}

I've used gs.info so that you can run this in a background script and see the output. The gs.info will produce a string in the following format: 

Name of Plugin + Current Version + Latest Version