PRINT INCIDENT CATEGORY HARDWARE & SOFTWARE WITH TOTAL COUNT IN GLIDERECORD

ARAVIND22
Tera Contributor

PLEASE HELP ME WITH THE BKOW SCRIPT TO GET THE TOTAL OF OF HARWARE AND SOFTWARE WITH LIST

 

var gr = new GlideRecord('incident');
gr.addQuery('category', 'software');

gr.addQuery('category', 'Hardware');
gr.query();
while(gr.next()){


OUTPUT NEEDED:

 

TOTAL NUMBER OF INCIDENT WITH HARDWARE CATEGORY IS  - 10

 

TOTAL NUMBER OF INCIDENT WITH SOFTWARE CATEGORY IS  - 12

 

Total number of incident is - 100

total number of incident with hardware and software is - 22

11 REPLIES 11

Harshal Sirsat
Tera Guru

Hi Arvind.
pls try this 

var gr= new GlideRecord('incident');
gr.addEncodedQuery('categoryINsoftware,hardware');

gr.query();
var ak=gr.getRowCount();
gs.print("total count hardware and software category ::"+ak);
while(gr.next())
{

gs.print(gr.category +"=>"+ gr.number);

}

 

output:

HarshalSirsat_0-1671107103311.png

Please mark as correct answer if this solves your issue.

 

Olu Oguns
Tera Contributor

Hi Aravind,

 

Try below:

 

var enc = 'active=true^category=hardware^ORcategory=Software'; // conditions
var activeIncident = new GlideRecord ('incident');//query the table
activeIncident.addEncodedQuery(enc);
activeIncident.query();
var gr = activeIncident.getRowCount();
gs.print("total number of incident: "+gr);
while(activeIncident.next()){

{
gs.print(activeIncident.category +":"+ activeIncident.number);
}
}