How to call Filter 'is one of' in Background Script

shaik_irfan
Tera Guru

Hello Everyone,

I have a requirement where i need to check wheather the incident are closed or not, i have more than 1000 records how to run the background scirpt to get count in one shot.

1 ACCEPTED SOLUTION

sanjay36
Kilo Guru

Hey Irfan,



You can form the queries in the query builder of the incident list . and then copy the query. by right clicking the filter and copy query like shown below



find_real_file.png



No write your script.



var gr = new GlideRecord('incident');


gr.addEncodedQuery('incident_stateIN6,7');


gr.query();


while(gr.next()){


// do something;


}



Thanks,


Sanjay


View solution in original post

9 REPLIES 9

sanjay36
Kilo Guru

Hey Irfan,



You can form the queries in the query builder of the incident list . and then copy the query. by right clicking the filter and copy query like shown below



find_real_file.png



No write your script.



var gr = new GlideRecord('incident');


gr.addEncodedQuery('incident_stateIN6,7');


gr.query();


while(gr.next()){


// do something;


}



Thanks,


Sanjay


Thanks Sanjay,



Can you please let me know when i run the background scirpt i am getting as Complete i want see the INC number what should i add


Kalaiarasan Pus
Giga Sage

Use GlideAggregate :



var count = new GlideAggregate('incident');


count.addAggregate('COUNT');


count.query();


var incidents = 0;


if (count.next())


    incidents = count.getAggregate('COUNT');



Add the encodedquery as per your need.


Where to add Encoded query ?