-1

In the cmdb_rel_ci table, I want to retrieve the value and total count of all the unique parent.sys_class_name values for Type(cmdb_rel_type) "Depends on::Used by".

I was trying to use with GlideAggregate, but classname is showing empty. Can anyone offer some advice?

Done With Fun
  • 45
  • 2
  • 14

2 Answers2

0

Use GlideAggregate on the cmdb_ci table, not cmdb_rel_ci. The rel table has no sys_class_name if I recall. You could also try dot-walking to it using GlideRecord, or using a Join query.

I don't know what "for type Depends on::Used by" means. Pretty sure it doesn't mean anything.

Please take the time to explain your questions clearly and include your code next time if you're expecting anyone to take time out of their day to help you.

Tim Woodruff
  • 600
  • 3
  • 9
0

As suggested already, use Glideaggregate (more info here)

Try this as an example:

var ga = new GlideAggregate('cmdb_rel_ci');
ga.addQuery('type.name', 'STARTSWITH', 'Depends on::Used by');
ga.addAggregate('COUNT', 'parent');
ga.query();
while (ga.next()) {
  var parent = ga.parent.getDisplayValue();
  var parentCount = ga.getAggregate('COUNT', 'parent');
  gs.info('CI ' + parent + ' has ' + parentCount + ' relationships with type Depends on::Used by');
}