API to get the incident count in servicenow

SireeshaV
Tera Contributor
 
4 ACCEPTED SOLUTIONS

Dnyaneshwaree
Mega Sage

Hello @SireeshaV ,

You can use the GlideAggregate API to get the incident count. Refer below example:

var ga = new GlideAggregate('incident');
ga.addAggregate('COUNT');
ga.query();

if (ga.next()) {
    var incidentCount = ga.getAggregate('COUNT');
    gs.info('Total number of incidents: ' + incidentCount);
}


 

Please accept my solution if it works for you and thumps up to mark it as helpful.
Thank you!!

Dnyaneshwaree Satpute
Tera Guru

View solution in original post

Mohan raj
Mega Sage

Hi @SireeshaV ,

 

Do you mean REST API or Glide API ?

View solution in original post

Harish Bainsla
Tera Sage
Tera Sage

Hi @SireeshaV  use Glide aggregate 

var ga = new GlideAggregate('incident');
ga.addAggregate('COUNT');
ga.query();
if (ga.next()) {
var incidentCount = ga.getAggregate('COUNT');

gs.print('Total number of incidents: ' + incidentCount);
} else {
gs.print('No incidents found.');
}
Screenshot 2024-07-10 at 5.34.44 PM.png

View solution in original post

SN_Learn
Kilo Patron
Kilo Patron

Hi @SireeshaV ,

 

You can utilize the Glide Aggregate API for this.

Navigate to Rest API Explorer and fill out the details as below:

 

[active^true] encoded query will filter all the active incident records.

SN_Learn_0-1720613027397.png

 

SN_Learn_1-1720613098286.png

 

Click on Send button, the response will be as below:

 

SN_Learn_2-1720613127573.png

 

Mark this as Helpful / Accept the Solution if this helps

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

View solution in original post

4 REPLIES 4

Dnyaneshwaree
Mega Sage

Hello @SireeshaV ,

You can use the GlideAggregate API to get the incident count. Refer below example:

var ga = new GlideAggregate('incident');
ga.addAggregate('COUNT');
ga.query();

if (ga.next()) {
    var incidentCount = ga.getAggregate('COUNT');
    gs.info('Total number of incidents: ' + incidentCount);
}


 

Please accept my solution if it works for you and thumps up to mark it as helpful.
Thank you!!

Dnyaneshwaree Satpute
Tera Guru

Mohan raj
Mega Sage

Hi @SireeshaV ,

 

Do you mean REST API or Glide API ?

Harish Bainsla
Tera Sage
Tera Sage

Hi @SireeshaV  use Glide aggregate 

var ga = new GlideAggregate('incident');
ga.addAggregate('COUNT');
ga.query();
if (ga.next()) {
var incidentCount = ga.getAggregate('COUNT');

gs.print('Total number of incidents: ' + incidentCount);
} else {
gs.print('No incidents found.');
}
Screenshot 2024-07-10 at 5.34.44 PM.png

SN_Learn
Kilo Patron
Kilo Patron

Hi @SireeshaV ,

 

You can utilize the Glide Aggregate API for this.

Navigate to Rest API Explorer and fill out the details as below:

 

[active^true] encoded query will filter all the active incident records.

SN_Learn_0-1720613027397.png

 

SN_Learn_1-1720613098286.png

 

Click on Send button, the response will be as below:

 

SN_Learn_2-1720613127573.png

 

Mark this as Helpful / Accept the Solution if this helps

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.