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.

Script to count

Avinash Dubey2
Tera Contributor

Write a script to display callers who have more than 5 incidents

1 ACCEPTED SOLUTION

Mohith Devatte
Tera Sage
Tera Sage

Hello @Avinash Dubey ,

TRY THIS SCRIPT

var arr=[];
var agg = new GlideAggregate('incident');
agg.addAggregate('COUNT', 'caller_id');
agg.query();
while (agg.next()) {
    //do things on the results
    var incidentCount = agg.getAggregate('COUNT', 'caller_id');

if(incidentCount>5)
{
arr.push(agg.caller_id.name.toString());
}
 }
gs.info(arr);

MARK MY ANSWER CORRECT IF IT HELPS YOU

View solution in original post

1 REPLY 1

Mohith Devatte
Tera Sage
Tera Sage

Hello @Avinash Dubey ,

TRY THIS SCRIPT

var arr=[];
var agg = new GlideAggregate('incident');
agg.addAggregate('COUNT', 'caller_id');
agg.query();
while (agg.next()) {
    //do things on the results
    var incidentCount = agg.getAggregate('COUNT', 'caller_id');

if(incidentCount>5)
{
arr.push(agg.caller_id.name.toString());
}
 }
gs.info(arr);

MARK MY ANSWER CORRECT IF IT HELPS YOU