The CreatorCon Call for Content is officially open! Get started here.

Incident Metric table - reporting off Value?

Shane J
Tera Guru

I've rediscovered the Incident Metric table and have been trying to do some reporting out of it.  The issue I can see with SNOOB (ServiceNow Out of Box) is that the 'Value' field is just a String, which means there's no way to dot-walk it.  That limits report possibilities considerably.

Am I missing something, or is this a problem others have had and have come up with some solution?  Right now in my Developer instance I added Reference fields for User and Group that get auto-populated when appropriate, so I can report through those.  I'm not sure that is the best solution however.

Thoughts?

4 REPLIES 4

Michael Fry1
Kilo Patron

Exactly what I saw and actions I took - added reference fields and populate those in the Metric. Did see any other options.

Well since great minds think alike - did you do anything to try to sum up durations?  Like if a single Assignment Group was sent the same Incident multiple times, finding their total duration for that Incident?  I'm having a heck of a time trying to get that to work.

Well after a few hours of beating on it, this BR on the Incident Metric table seems to work:

 

find_real_file.png

 

(function executeRule(current, previous /*null when async*/) {

var tvdsum = 0;

var gr = new GlideRecord('metric_instance');
gr.addQuery('id', '=', current.id);
gr.addQuery('definition', '=', current.definition);
gr.addQuery('value', '=', current.value);
gr.orderByDesc('sys_created_on');
gr.query();

while (gr.next()){
// gs.addInfoMessage(gr.sys_created_on);
// gs.addInfoMessage(gr.duration.dateNumericValue());
tvdsum += gr.duration.dateNumericValue();
gr.u_total_value_duration = '';
gr.update();
}
current.u_total_value_duration.setDateNumericValue(current.duration.dateNumericValue() + tvdsum);

})(current, previous);

 

EDIT:  Updated the formula to one that works.  😉

 

Nice! Hadn't done anything like that, but that's helpful.