About

Monday, 8 November 2021

Total record count using GlideRecord in ServiceNow

It can also be executed using glideAggregate 


var inc = new GlideRecord('incident');

//inc.addActiveQuery();

inc.query();

var cat=["inquiry" , "software" , "hardware" , "network" , "database"];

var c1=0, c2=0, c3=0, c4=0, c5=0 , c6=0;

while(inc.next())

{

if(inc.category == cat[0])

{

c1++;

//gs.addInfoMessage(inc.number+" = "+" , "+c1+"  "+cat[0]);

}

else if(inc.category == cat[1])

{

c2++;

//gs.addInfoMessage(inc.number+" = "+" , "+c2+"  "+cat[1]);

}

else if(inc.category == cat[2])

{

c3++;

//gs.addInfoMessage(inc.number+" = "+" , "+c3+"  "+cat[2]);

}

else if(inc.category == cat[3])

{

c4++;

//gs.addInfoMessage(inc.number+" = "+" , "+c4+"  "+cat[3]);

}

else if(inc.category == cat[4])

{

c5++;

//gs.addInfoMessage(inc.number+" = "+" , "+c5+"  "+cat[4]);

}

else if(inc.category == "")

{

c6++;

gs.addInfoMessage(inc.number+" = "+" , "+c6+"  BLANK CATEGORY");

}

}

gs.addInfoMessage("Category = "+cat[0]+" , total number of record = "+c1);

gs.addInfoMessage("Category = "+cat[1]+" , total number of record = "+c2);

gs.addInfoMessage("Category = "+cat[2]+" , total number of record = "+c3);

gs.addInfoMessage("Category = "+cat[3]+" , total number of record = "+c4);

gs.addInfoMessage("Category = "+cat[4]+" , total number of record = "+c5);

gs.addInfoMessage("Category = BLANK CATEGORY , total number of record = "+c6);


gs.addInfoMessage(inc.getRowCount());

No comments:

Post a Comment