- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi Team,
I have been asked to write the code align with the Below Image..
I have used glideAggrette.. But state is showing like 2,3 but not showing in display name and this bog space how to give.
My Code :-
var x=new GlideAggregate('incident');
x.addAggregate('COUNT','state');
x.query();
while(x.next()){
gs.print(x.state.+grIncident. getAggregate('COUNT','state'));
}
not getting the below Output
@David my Post is always getting in unapproved phase. Help me
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @vidishaagarwal5
You need to change the Code to the below code
gs.print('State\\tIncident Count');
var x=new GlideAggregate('incident');
x.addAggregate('COUNT','state');
x.query();
while(x.next()){
gs.print(x.state. getDisplayValue()+'\t'+x. getAggregate('COUNT','state'));
}
This will Help
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
3 weeks ago
Hi @vidishaagarwal5
You need to change the Code to the below code
gs.print('State\\tIncident Count');
var x=new GlideAggregate('incident');
x.addAggregate('COUNT','state');
x.query();
while(x.next()){
gs.print(x.state. getDisplayValue()+'\t'+x. getAggregate('COUNT','state'));
}
This will Help
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
3 weeks ago
Try this,
gs.print('State\tIncident Count');
var incAggregate=new GlideAggregate('incident');
incAggregate.addAggregate('COUNT','state');
incAggregate.addQuery('state','IN','2,3,7');
incAggregate.query();
while(incAggregate.next()){
gs.print(incAggregate.state.getDisplayValue() + '\t' + incAggregate.getAggregate('COUNT','state'));
}
If this helped to answer your query, please mark it helpful & accept the solution.
Thanks,
Bhuvan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I guess you have added extra Line in query.. which I don't need.. seems to be AI answer.. anyway thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
This is a standard glide aggregate query and not sure why you assume we need AI to answer it.
https://developer.servicenow.com/blog.do?p=/post/glideaggregate/
As per your requirement, not all the incident states are aggregated and it queries for incidents in status one of 'In Progress, On Hold, Closed'.
Please do not assume without knowing the source.
Thanks,
Bhuvan