- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Hi Everyone,
I am planning to start a weekly dose of ServiceNow features in Washington DC release. Please add your comments and let me know if I am missing anything.
Week 1: setIntervalYearIncluded()
With Washington DC release, ServiceNow brought a new GlideAggrigate API method "setIntervalYearIncluded()" for scoped and global applications.
This method lets you decide whether to group results by year for day-of-week trends or not. These trends can be created by using addTrend() method with dayofweek time interval. It is a Boolean type method and with the parameters as true or false you can either group the results by year or exclude it respectively in your result. By default, the result with addTrend() shows the year in the trend along with the day of week.
Sample script to display the count of incident records separated by the day of week without including the year.
var incGr = new GlideAggregate('incident');
incGr.addTrend('sys_created_on','dayofweek');
incGr.addAggregate('COUNT');
incGr.setIntervalYearIncluded(false);
incGr.query();
while(incGr.next()){
gs.info(incGr.getValue('timeref')+': '+incGr.getAggregate('COUNT'));
}
Output:
Note: It will only work with day-of-week trend. You can find the official documentation here.
Regards,
Mohit Kaushik
2XServiceNow MVP (2023-2024)
- 941 Views
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
