How to get the count of incident table in list form

p t1
Kilo Sage
Kilo Sage

How to get the count of incident table in list form

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Pallavi,

There is only 1 script which would run on incident list i.e. ui script. Have a ui script and check if the url is of incident table then query the incident table and alert the total incidents present in the table.

Sample script below: UI Script

(function() {
addAfterPageLoadedEvent(function () {

// this will tell whether it is incident table list layout

if(window.location.href.indexOf('incident_list') != -1){

getIncidentCount();
}

});
})();

function getIncidentCount(){

var gr = new GlideRecord('incident');

gr.query();

var rowCount = gr.rows.length;

alert("Total incidents are " + rowCount);

}

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

rahamathulla
Kilo Contributor

var gr = new GlideRecord('incident');

gr.addQuery('active', 'true');

gr.query();

if(gr.next()){

gs.info('Record in incident total list:' + gr.getRowCount());

}