GlideAggregate Error: Skip invalid GroupBy condition: ORDERBYundefined

NehaSNOW
Tera Guru

Hi Members,

 

I am running the below GlideAggregate script in the Script Backgroung to get the Count of the Incidents per the State wise.
Issue: - Getting the error: - 
Skip invalid GroupBy condition: ORDERBYundefined
*** Script: NEHA COUNT of Incidents 187
Please suggest.
Script: -
var gaCount = new GlideAggregate('incident');
gaCount.addAggregate('COUNT',gaCount.number);
gaCount.groupBy(gaCount.state);
gaCount.query();

while(gaCount.next()){
gs.info("NEHA COUNT of Incidents "+gaCount.getAggregate('COUNT',gaCount.number));
}
 
Thanks,
Neha Pateria
1 ACCEPTED SOLUTION

Chaitanya ILCR
Giga Patron

Hi @NehaSNOW ,

try this

var gaCount = new GlideAggregate('incident');
gaCount.addAggregate('COUNT');
gaCount.groupBy('state');
gaCount.query();

while (gaCount.next()) {
    gs.info("NEHA COUNT of Incidents " + gaCount.state.getDisplayValue() + ' ' + gaCount.getAggregate('COUNT'));
}

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

View solution in original post

4 REPLIES 4

Chaitanya ILCR
Giga Patron

Hi @NehaSNOW ,

try this

var gaCount = new GlideAggregate('incident');
gaCount.addAggregate('COUNT');
gaCount.groupBy('state');
gaCount.query();

while (gaCount.next()) {
    gs.info("NEHA COUNT of Incidents " + gaCount.state.getDisplayValue() + ' ' + gaCount.getAggregate('COUNT'));
}

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Ankur Bawiskar
Tera Patron

@NehaSNOW 

your syntax and script for GlideAggregate is wrong.

Use script shared by @Chaitanya ILCR 

More details here

Understanding GlideAggregate 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Ravi Gaurav
Giga Sage

Hi @NehaSNOW 

Can you please try the below please :-

 

var x= new GlideAggregate('incident');
x.addAggregate('COUNT'); 
x.groupBy('state'); 
x.query();

while (x.next()) {
gs.info("NEHA COUNT of Incidents in State " + x.getValue('state') + " : " + x.getAggregate('COUNT'));
}
Output :-
*** Script: NEHA COUNT of Incidents in State 1 : 45
*** Script: NEHA COUNT of Incidents in State 2 : 32

Vasanthi_L
Tera Contributor
Hi,
 
var ga = new GlideAggregate('incident');
ga.addAggregate('COUNT','state');
ga.query();
while (ga.next()){
    gs.info(ga.state.getDisplayValue()  + " " +ga.getAggregate('COUNT','state'));
}
 
Regards