Script

BharatiK
Tera Contributor

Hi,  

 

I want to show the result like below using script.

BharatiK_0-1738385936179.png

 

How to achieve this?

 

 

Script:

var inc = new GlideRecord ('incident');
inc.query();
while (inc.next())
{
gs.print (inc.state);
gs.getRowCount (inc.state);
}

 

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@BharatiK 

something like this using GlideAggregate

var gaInc = new GlideAggregate('incident');
gaInc.addAggregate('count');
gaInc.orderByAggregate('count');
gaInc.groupBy('state'); 
gaInc.query();
while(gaInc.next()){
var count = gaInc.getAggregate('count');
gs.info('State: ' + gaInc.state.getDisplayValue() + ' has incidents : ' + count);
}

Output:

AnkurBawiskar_0-1738387623847.png

 

AnkurBawiskar_1-1738387647599.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@BharatiK 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@BharatiK 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

MadisonFlores
Tera Contributor

Looks good! Just adjust the print statement for the desired output.

Now, it is my turn to help you, and I would like to share the https://academized.com/do-my-homework website with you. If you want someone to do your homework, then you can take help from Academized professional essay writers.