How to do dot walking in groupBy() method.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 08:23 AM
Hi,
For Example: By doing GlideRecord on incident table, i want to filter records groupby assignment group managers
var agg = new GlideAggregate('incident');
agg.addQuery('active=true');
agg.groupBy('assignment_group.manager');
agg.query();
While(gr.next){
}
For above code, result showing empty.
Could you please suggest on this.
Thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 08:37 AM - edited 11-18-2022 08:49 AM
Hi @Charan123,
Take a look at this article. It might help you on achieve it:
https://hi.service-now.com/kb_view.do?sysparm_article=KB0745198
var agg = new GlideAggregate('incident');
agg.addQuery('active=true');
agg.addAggregate('COUNT', 'assignment_group.manager');
agg.orderByAggregate('COUNT' , 'assignment_group.manager');
agg.query();
while(agg.next()){
gs.info("Sagar: " + agg.getAggregate('COUNT', 'assignment_group.manager'));
}
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2022 01:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2022 09:02 AM
Hi @Charan123,
Please use below script-
var agg = new GlideAggregate('incident');
agg.addQuery('active=true');
agg.groupBy('assignment_group.manager');
agg.setLimit(10)
agg.query();
while(agg.next()){
gs.info(agg.getValue('assignment_group.manager'))
}
Please try running above script in background, you ll get sys_id of manager.
Please mark the answer as correct, If I answered your query. It will be helpful for others who are looking for similar questions.
Regards
Saurabh
Thanks and Regards,
Saurabh Gupta