Using GlideAggregate group by Month
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2011 12:32 AM
Hello, I'm trying to get a list of created and close incidents by month using the GlideAggregate object. The same you'd get creating a trend report.
I've tried to set a trend and then an aggregate:
var trend = new GlideAggregate('incident');
trend.setTrend ('opened_at','Month');
trend.addAggregate('COUNT');
trend.query();
so far, it seems that the setTrend method does nothing as I'm getting just one record with the count of all the incidents.
How the setTrend method must be used? Couldn't find any example in the wiki. How can I access the Month value from the query results?
Thanks in advance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2011 07:13 AM
I think you might want trend.setGroup(false).
var trend = new GlideAggregate('incident');
trend.addTrend ('opened_at','Month');
trend.addAggregate('COUNT');
trend.setGroup(false);
trend.query();
while(trend.next()) {
gs.print(trend.getValue('timeref') + ': ' + trend.getAggregate('COUNT'));
}
(took me a while to work out how to get the time base. We don't seem to have that documented.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2011 09:07 AM
Thank you very much, setting the setGroup property to false did the trick.
It would be very useful to include examples of all GlideAggregate methods in the Wiki.
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2013 08:23 AM
Thank you. I'm curious to know how did you come up with this, as there is no documentation?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2014 05:05 AM
Hi James,
It was helpful to get the trend value from using 'timeref' in getValue method. However; there is another reference variable 'yearref', whose value was fetched as null using the getValue method. Also, the timeref returns the output as "year/year". How can we get the "yearref" value ?