How to get the count of incident table in list form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2018 01:30 AM
How to get the count of incident table in list form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2018 01:38 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2021 10:34 PM
var gr = new GlideRecord('incident');
gr.addQuery('active', 'true');
gr.query();
if(gr.next()){
gs.info('Record in incident total list:' + gr.getRowCount());
}