Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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
Tera Expert

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

Chandu Telu
Tera Guru

you use encoded query like this: active=true^categoryINrequest,inquiry,software


ar gr = new GlideRecord('incident'); gr.addEncodedQuery('active=true^categoryINrequest,inquiry,software'); gr.query(); while(gr.next()){ // do something; }


preddy
Kilo Guru

Hi Irfan,



You can check How many Active incidents are there in Incident Table.



var gr = new GlideRecord('incident');


gr.addActiveQuery();


gr.query();


if(gr.next()){


gs.print("Count : "+gr.getRowCount());


}


Pavan,



I have 1000 of correlation_ids with this i need to check how many are Closed & How many are opened. Can you please help me out with this