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.

GlideAggregate COUNT returns null

thomaskennedy
Tera Guru
var gr_agg = new GlideAggregate("cmn_location");
gr_agg.addEncodedQuery("name=Americas");
gr_agg.aggAggregate("COUNT");
gr_agg.query();
gr_agg.next();
var count = gr_agg.getAggregate("COUNT");
gs.info("count is " + count);

 

This returns null. I'm running it in a console script, in global scope. I've tried supplying a second param (null) to addAggregate().

1 ACCEPTED SOLUTION

Muhammad Khan
Mega Sage

Seems like there is a typo in your script.

Replace

gr_agg.aggAggregate("COUNT");

With

gr_agg.addAggregate("COUNT");

View solution in original post

2 REPLIES 2

Muhammad Khan
Mega Sage

Seems like there is a typo in your script.

Replace

gr_agg.aggAggregate("COUNT");

With

gr_agg.addAggregate("COUNT");

thomaskennedy
Tera Guru

That's it, thank you!