Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Aggregate an indicator by SUM duration on unique records

Blair5
Tera Guru

I've created an indicator on the TASK_CI table and want to sum the duration of the unique TASK's open duration. Currently, I can only SUM the total records of the TASK_CI.

 

For example, 2 tasks (incidents) are created both totaling 60 minutes each for a total of 120 min.

 

However, if each task has 5 CIs associated with them, the duration is summed by total rows (10) in the TASK_CI table and not by the 2 unique TASK (incident) records. 

 

See below for the script I'm using for the SUM of the duration - pretty basic. I understand it calculates the duration for each record, but I want to exclude the record if it already appears in the calculation. 

 

Any help is appreciated:

 

 

var diff = function(x, y) {
    return y.dateNumericValue() - x.dateNumericValue();
};
var min = function(x, y) {
    return diff(x, y) / (1000 * 60);
};

min(current.task.opened_at, current.task.closed_at);

 

0 REPLIES 0