diff --git a/GlideAggregate/getTotal of aggregate value/README.MD b/GlideAggregate/getTotal of aggregate value/README.MD new file mode 100644 index 0000000000..e928f2699c --- /dev/null +++ b/GlideAggregate/getTotal of aggregate value/README.MD @@ -0,0 +1,6 @@ +### GlideAggregate - getTotal() + +#### Script to get total of aggregate value + +Example +To show total number of closed P1 incidents which was illustrated in a trend (count of incident every month). diff --git a/GlideAggregate/getTotal of aggregate value/getTotal.js b/GlideAggregate/getTotal of aggregate value/getTotal.js new file mode 100644 index 0000000000..459fff14d8 --- /dev/null +++ b/GlideAggregate/getTotal of aggregate value/getTotal.js @@ -0,0 +1,10 @@ +var trend = new GlideAggregate('incident'); +trend.addTrend ('closed_at','month'); +trend.addQuery('priority',1); +trend.addQuery('state',7); +trend.addAggregate('COUNT'); +trend.query(); +while(trend.next()) { + gs.print(trend.getValue('timeref') + ': ' + trend.getAggregate('COUNT')); +} +gs.print('Total closed incidents: ' + trend.getTotal('COUNT')); \ No newline at end of file