Scripting in Performance Analytics

Performance Analytics provides several script objects for use in scripts and APIs for querying Performance Analytics data. The scripts serve as breakdown mappings or to calculate a value from an indicator.

A breakdown mapping script typically returns either a sys_id of a breakdown element or an integer to put the score in a bucket. Indicator scripts return a score calculated from one or more fields. The same script can serve both as a breakdown mapping script and as an indicator script. For example, consider the provided Incident.Age.Days script, which uses the opened_at field from the incident table. This script serves as a breakdown mapping for the Age breakdown, which uses the Incident Age Ranges (Days) bucket group as the breakdown source.

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);

In this example, current.opened_at gets the timestamp of when the currently evaluated record was opened. The score_end script variable comes from the data collector and is bound to the period being collected. For example, if a monthly indicator is being collected, the score_end is the end of the month. Here the timestamp of when the incident was opened is subtracted from the timestamp of the end of the collection period and the result is converted to days.


This example includes the Incident.opened_at field, which is specified in the Fields field for this script. You can use score_start and score_end without defining them in the Fields field.