We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to get class wise CI count which are active?

Aman Sahu
Tera Contributor

How to get class wise CI count which are active?

1 REPLY 1

Muhammad Khan
Mega Sage

Hi,

Use below code in background script.

var count = new GlideAggregate('cmdb_ci');
count.addAggregate('COUNT', 'sys_mod_count');
count.groupBy('sys_class_name');
count.query();   

while (count.next()) {  
  var counts = count.getAggregate('COUNT', 'sys_mod_count');
  var className = count.sys_class_name.getDisplayValue();
  gs.print(className + ' Count= ' + counts);
}

 

Output

find_real_file.png