how i get the count of incidents which are created last month not in last 30 days with out specifying any date using background script

suprakash
Giga Expert

how i get the count of incidents which are created last month not in last 30 days with out specifying any date   using background script, without using any report types I dont want want to specify any date any month. suppose i am checking using background script in december   the count will display the no. of incidents for the month of november .... how can i do it??

1 ACCEPTED SOLUTION

drjohnchun
Tera Guru

Please try



var ga = new GlideAggregate('incident');
ga.addQuery('opened_atONLast month@javascript:gs.beginningOfLastMonth()@javascript:gs.endOfLastMonth()');
ga.addAggregate('COUNT');
ga.query();
var incidents_opened = ga.next() ? ga.getAggregate('COUNT') : 0;
gs.info(incidents_opened);



Please feel free to connect, follow, mark helpful / answer, like, endorse.


John Chun, PhD PMP see John's LinkedIn profile

visit snowaid


ServiceNow Advocate

View solution in original post

12 REPLIES 12

Please try



// get the month name of the previous month


var monthNames = ',December,January,February,March,April,May,June,July,August,September,October,November'.split(',');


gs.info(monthNames[new GlideDate().getMonthLocalTime()]);


Thanks a lot, John.


rajesh47
Kilo Contributor

How can i display last 3moths incident records using script