How to apply Glide aggregate groupby when I'm using GlideFilter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2023 12:01 PM
Hi Guys,
I working in a code, but it didn't work. I need to use Glidefilter and the result should be grouped by manager, someone know is its possible?
Following my code:
var now_GR = new GlideAggregate('sys_user_group');
now_GR.groupBy("manager"); //If you comment this line the code will work but with the total and not the result grouped by manager as I need.
now_GR.orderByAggregate('COUNT');
now_GR.query();
var condition = 'active=false';
var filter = new GlideFilter(condition, 'filterCondition');
var countResults = 0;
while (now_GR.next()) {
if (filter.match(now_GR, true))
countResults++;
}
gs.info(countResults);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2023 01:53 PM
Hi @sushantmalsure it worked, but only when the condition field is boolean, I tried the condition with another type and didnt worked.
Is possible to fix it?
var now_GR = new GlideAggregate('sys_user_group');
now_GR.groupBy("manager");
now_GR.addAggregate('COUNT');
now_GR.query();
var condition = 'parent=c042b0661ba73810b4266572f54bcbf6';
var filter = new GlideFilter(condition, 'filterCondition');
var countResults = 0;
while (now_GR.next()) {
if (filter.match(now_GR, true))
countResults++;
}
gs.info(countResults);
Many thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2023 02:01 PM
Can you help me understand your complete requirement? I think I am confused with what you are trying to do..
Regards,Sushant Malsure