- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2018 09:15 AM
Hi,
I want to display the top 3 catalog items based on the volume of tickets raised.
Please help!!
Thanks,
Gopi
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2018 12:50 PM
Background script? You can do something like this:
var limit = 3;
var items = [];
var count = new GlideAggregate('sc_req_item');
count.addAggregate('COUNT','cat_item');
count.groupBy('cat_item');
count.addQuery('cat_item.sys_class_name', 'NOT IN', 'sc_cat_item_guide,sc_cat_item_wizard,sc_cat_item_content');
count.orderByAggregate('COUNT', 'cat_item');
count.query();
while (count.next() && items.length < limit) {
var item = {};
item.count = count.getAggregate('COUNT', 'cat_item');
item.name = count.cat_item.name.getDisplayValue();
item.short_description = count.cat_item.short_description.getDisplayValue();
item.picture = count.cat_item.picture.getDisplayValue();
item.price = count.cat_item.price.getDisplayValue();
item.hasPrice = count.cat_item.price != 0;
item.sys_id = count.cat_item.sys_id.getDisplayValue();
items.push(item);
}
for (var i = 0; i < items.length; i++) {
var line = items[i];
gs.print(line.name);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2018 08:35 PM
Thanks Michael 🙂
This worked !!