About

Monday, 8 November 2021

Basic codes in ServiceNow

 var count = new GlideAggregate('incident');

count.addAggregate('COUNT');

count.query();

var incidents = 0;          

if(count.next()) 

   incidents = count.getAggregate('COUNT');    // we can directly print the count

gs.addInfoMessage(incidents);



gs.addInfoMessage(now_GR.getRowCount());



var count = new GlideAggregate('incident');

count.addQuery('active', 'true');

count.addAggregate('COUNT');

count.query();

var incidents = 0;

if(count.next()) 

   incidents = count.getAggregate('COUNT');

gs.a


----------------------------------------------------


Glide Aggregiate:-


var count = new GlideAggregate('incident');

count.addAggregate('COUNT');

count.query();

var incidents = 0;          

if(count.next()) 

   incidents = count.getAggregate('COUNT');    // we can directly print the count

gs.addInfoMessage(incidents);




gs.addInfoMessage(now_GR.getRowCount());

var count = new GlideAggregate('incident');

count.addQuery('active', 'true');

count.addAggregate('COUNT');

count.query();

var incidents = 0;

if(count.next()) 

   incidents = count.getAggre

var count = new GlideAggregate('incident');

count.addQuery('active','true');

count.addAggregate('COUNT','category');

count.query();

while(count.next()){

  var category = count.category;

  var categoryCount = count.getAggregate('COUNT','category');

  gs.log("there are currently "+ categoryCount +" incidents with a category of "+ category);}


same for glide record try....



var incidentGA = new GlideAggregate('incident');

incidentGA.addAggregate('COUNT');

incidentGA.addAggregate('SUM');

incidentGA

No comments:

Post a Comment