- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2021 06:47 AM
unable to get the Value of short description using GlideAggregate
var agg = new GlideAggregate('incident');
agg.addAggregate('COUNT', 'category');
agg.orderBy('assigned_to');
agg.orderBy('state');
agg.addQuery('sys_created_on', '>=', 'javascript:gs.beginningOfLast12Months()');
agg.query();
while (agg.next()) {
gs.print(agg.getValue("short_description"));
}
Note: i doesnt want to use GlideRecord .
Is it possible to get the value of a field using GlideAggregate
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2021 08:41 AM
Hi
Try out this
var agg = new GlideAggregate('incident');
agg.addAggregate('MAX', 'reopen_count');
agg.orderByDesc('short_description');
agg.orderBy('state');
agg.addQuery('sys_created_on', '>=', 'javascript:gs.beginningOfLast12Months()'); agg.query();
if(agg.next()) {
gs.print(agg.getValue("short_description"));
}
Regards,
Harika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2021 07:18 AM
add orderBy and use
var agg = new GlideAggregate('incident');
agg.addAggregate('COUNT', 'category');
agg.orderBy('short_description');
agg.orderBy('assigned_to');
agg.orderBy('state');
agg.addQuery('sys_created_on', '>=', 'javascript:gs.beginningOfLast12Months()');
agg.query();
while (agg.next()) {
gs.print(agg.getValue("short_description"));
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2021 08:12 AM
Actually im trying to retrive the max values of Short Description.
var agg = new GlideAggregate('incident');
agg.addAggregate('MAX', 'reopen_count');
agg.orderBy('short_description');
agg.addQuery('sys_created_on', '>=', 'javascript:gs.beginningOfLast12Months()');
agg.query();
if(agg.next()) {
gs.print(agg.getValue("short_description"));
}
in this case though i used order by its not getting me the max values short description
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2021 08:32 AM
MAX, MIN etc would work on integer field and not string field
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2021 08:57 PM
Did you accidentally marked other response as correct.
The question you asked was for getting field value using GlideAggregate which I already shared but the response marked as correct is for using MAX value.
Please ensure the question and answer relates so that it doesn't confuse the future readers.
Please mark appropriate response as correct so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2021 08:30 AM
Would you mind marking my response as correct if I was able to help/guide you.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader