- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2025 12:19 AM
Hi Members,
Skip invalid GroupBy condition: ORDERBYundefined
*** Script: NEHA COUNT of Incidents 187
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2025 12:37 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2025 12:37 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2025 12:44 AM
your syntax and script for GlideAggregate is wrong.
Use script shared by @Chaitanya ILCR
More details here
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2025 01:00 AM
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
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2025 01:27 AM - edited 03-13-2025 12:45 AM