Scripted Indicator scores repeating across breakdown elements

venori26
Tera Contributor

Hello Team,

 

I have written an indicator script but the scores are repeating across breakdown elements. the scores are showing correct if I individuation filter a query with an element of a breakdown. adding my script below. The script is about calculating 'past due days' of an incident category. Each category has multiple incidents and each incident has a resolution date.  So when I show past due days at category level, i need to pick the earliest due date among all the incidents of that particular category.  And then I subtract that date with the current day to get the number of past due days: How to address this issue? thanks in advance. 

 

(function() {
var ga = new GlideRecord('incident');
var now = new GlideDateTime();
//ga.addQuery('category','Hardware');
ga.orderBy('opened_at_date'); // earliest first
ga.setLimit 1); // only need the earliest
ga.query();

if (ga.next()) {

var minGdt = new GlideDateTime(ga.getValue('opened_at_date'));
var today = new GlideDateTime();
var diffDays = Math.floor((today.getNumericValue() - minGdt.getNumericValue()) / (1000*60*60*24));
return diffDays;
}
return 0;
})();

venori26_0-1757539398683.png

 

0 REPLIES 0