Example: Script mapping
The Age breakdown uses the Incident.Age.Days script to calculate the age of incidents in days and map the values to the Incident Age Ranges bucket group.
In the first two images, you see the Age breakdown, which uses the Incident.Age.Days breakdown source and the Incident.Age.Days script for breakdown mapping. You also see that the breakdown source refers to the Incident Age Range (Days) bucket group.
The Incident.Age.Days script takes the time stamp when the incident was opened from the incident table and subtracts this from the time stamp at the end of the collection period. The script converts this value from milliseconds to days.
var diff=function(x,y){return y.dateNumericValue() - x.dateNumericValue();};
var days=function(x,y){return diff(x,y)/(24*60*60*1000);};
days(current.opened_at, score_end);
The resulting numbers of days are sorted into the buckets of the bucket group.
Here is the result of running this script on the Number of open incidents indicator.