setGroup(false): What is exact use of this method? Beacause of this my output also changes

IAmIshan
Tera Guru

If I comment this method(setWorkflow), then my other methods output gets wrong.....


var ga = new GlideAggregate('u_empdata');
ga.addAggregate('SUM', 'u_salary');
ga.addAggregate('COUNT','u_salary');
ga.addAggregate('AVG', 'u_salary');
ga.addAggregate('MIN', 'u_salary');
ga.addAggregate('MAX', 'u_salary');

//ga.setGroup(false);
ga.query();
if (ga.next()) {
gs.log('Total: ' + ga.getAggregate('SUM', 'u_salary'));
 gs.log('Num: ' + ga.getAggregate('COUNT', null));
gs.log('Average: ' + ga.getAggregate('AVG', 'u_salary'));
gs.log('Min: ' + ga.getAggregate('MIN', 'u_salary'));
gs.log('Max: ' + ga.getAggregate('MAX', 'u_salary') + '\n');
}

1 ACCEPTED SOLUTION

Paritosh
Giga Expert

hi,

the reason to setWorkflow(false) is 

1. when working on incident or any other custom table, there are chances that in background lot of Workflows might be executing.

so, If particular workflow is active at this time, it may manipulate our answer. this hampers our solution.

hope, this solves your doubt..

Thank you

View solution in original post

2 REPLIES 2

Community Alums
Not applicable

This is to tell the Ajax that the results should be grouped. 

You can see the documentation for this method here: https://developer.servicenow.com/dev.do#!/reference/api/orlando/server/no-namespace/c_GlideAggregate...

Paritosh
Giga Expert

hi,

the reason to setWorkflow(false) is 

1. when working on incident or any other custom table, there are chances that in background lot of Workflows might be executing.

so, If particular workflow is active at this time, it may manipulate our answer. this hampers our solution.

hope, this solves your doubt..

Thank you