Print Active and incative incident with get rowcount
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2022 09:08 PM
Hello Guys,
Can you help me to print below use case in gliderecord:
Print Active and incative incident with get rowcount
Regards,
Aravind

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2022 09:17 PM
//Active Incident
var arrInc = [];
var grInc = new GlideRecord("incident");
grInc.addActiveQuery(); //use this to return active incidents
grInc.query();
gs.info('Total Active Incident : '+grInc.getRowCount());
while (grInc.next()) {
arrInc.push(grInc.getValue("number"));
}
gs.info(arrInc);
//Inactive incident
var arrInc = [];
var grInc = new GlideRecord("incident");
grInc.addInactiveQuery(); //use this to return active incidents
grInc.query();
gs.info('Total InActive Incident : '+grInc.getRowCount());
while (grInc.next()) {
arrInc.push(grInc.getValue("number"));
}
gs.info(arrInc);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2022 09:39 PM
Bhai I need to print both in a single script not seperate

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2022 09:47 PM
var arrInc = [];
var grInc = new GlideRecord("incident");
//use this to return active incidents
grInc.query();
var vactive = 0;
var vinActive = 0;
var arrActive = [];
var arrInActive = [];
while (grInc.next()) {
if ( grInc.getValue('active') == true ) {
arrActive.push(grInc.getValue("number"));
vactive = vactive + 1;
} else {
arrInActive.push(grInc.getValue("number"));
vinActive = vinActive + 1;
}
}
gs.print('ACTIVE INCIDENT COUNT : '+ vactive);
gs.print('ACTIVE INCIDENTS : '+ arrActive);
gs.print('INACTIVE INCIDENT COUNT : '+ vinActive);
gs.print('INACTIVE INCIDNET : '+ arrInActive);
1. You cannot use getrowcount here.
2. Either you can use GlideAggregate and Group by
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2022 10:02 PM - edited 12-14-2022 10:03 PM
@ARAVIND22 You can use GlideAggregate to achieve this as below
ServiceNow Community Rising Star, Class of 2023