Show incident count for each state

SandeepKSingh
Kilo Sage

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

2 ACCEPTED SOLUTIONS

Ravi Gaurav
Giga Sage

Hi @SandeepKSingh 

 

I guess you are looking for the below image :-

RaviGaurav_0-1724421092888.png

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'));
}

 

 

View solution in original post

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.

View solution in original post

3 REPLIES 3

AndersBGS
Tera Patron

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

Ravi Gaurav
Giga Sage

Hi @SandeepKSingh 

 

I guess you are looking for the below image :-

RaviGaurav_0-1724421092888.png

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'));
}

 

 

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.