- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2024 11:05 PM
I need to write a script to show incident count for each state which are updated today and store in a custom field on Incident table
Do help me on the same
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2024 06:52 AM
I guess you are looking for the below image :-
If yes then please use the below code that will help you :-
Script :
gs.print('State\\tIncident Count');
var grIncident=new GlideAggregate('incident');
grIncident.addEncodedQuery(' sys_updated_onONToday@javascript: gs.beginningOfToday()@javascript: gs.endOfToday()');
grIncident.addAggregate('COUNT','state');
grIncident.query();
while(grIncident.next()){
gs.print(grIncident.state. getDisplayValue()+'\t'+grIncident. getAggregate('COUNT','state'));
}
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
08-23-2024 06:56 AM
Exactly I was looking for the same .
Thanks @Ravi Gaurav big fan of yours and your youtube channel.
Thanks a lot to answer all mu queries.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2024 06:32 AM
Hi @SandeepKSingh ,
I don't follow the requirement. Can you try to specify the use case?
if my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2024 06:52 AM
I guess you are looking for the below image :-
If yes then please use the below code that will help you :-
Script :
gs.print('State\\tIncident Count');
var grIncident=new GlideAggregate('incident');
grIncident.addEncodedQuery(' sys_updated_onONToday@javascript: gs.beginningOfToday()@javascript: gs.endOfToday()');
grIncident.addAggregate('COUNT','state');
grIncident.query();
while(grIncident.next()){
gs.print(grIncident.state. getDisplayValue()+'\t'+grIncident. getAggregate('COUNT','state'));
}
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
08-23-2024 06:56 AM
Exactly I was looking for the same .
Thanks @Ravi Gaurav big fan of yours and your youtube channel.
Thanks a lot to answer all mu queries.