- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 09:23 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 02:03 AM - edited 05-28-2024 02:06 AM
Hi @Ramachandra ,
Here is an example of Background script on how to display count and categories from Incident Table using Glide Aggregate:
// Create a new GlideAggregate object for the 'incident' table
var ga = new GlideAggregate('incident');
// Group by the 'category' field
ga.groupBy('category');
// Count the number of incidents in each category
ga.addAggregate('COUNT');
// Query the table
ga.query();
// Iterate through the results and display the category and the count
while (ga.next()) {
var category = ga.getValue('category');
var count = ga.getAggregate('COUNT');
gs.print('Category: ' + category + ', Count: ' + count);
}
Result:
If you find my response helpful, please consider selecting "Accept as Solution" and "Helpful" .
Thanks,
Anusha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2024 02:03 AM - edited 05-28-2024 02:06 AM
Hi @Ramachandra ,
Here is an example of Background script on how to display count and categories from Incident Table using Glide Aggregate:
// Create a new GlideAggregate object for the 'incident' table
var ga = new GlideAggregate('incident');
// Group by the 'category' field
ga.groupBy('category');
// Count the number of incidents in each category
ga.addAggregate('COUNT');
// Query the table
ga.query();
// Iterate through the results and display the category and the count
while (ga.next()) {
var category = ga.getValue('category');
var count = ga.getAggregate('COUNT');
gs.print('Category: ' + category + ', Count: ' + count);
}
Result:
If you find my response helpful, please consider selecting "Accept as Solution" and "Helpful" .
Thanks,
Anusha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2024 10:45 PM
Thank You @Anusha Reddy VK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2024 10:52 PM
Hi Anusha Reddy,
Display 10 incidents(number,caller,category) which were created between 1 january 2022 and 1
march 2023 and category is hardware .
guide me Please
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2025 07:00 AM
var gr = new GlideRecord('incident');
gr.addQuery('category', 'hardware');
gr.addQuery('sys_created_on', '>=', '2022-01-01 00:00:00');
gr.addQuery('sys_created_on', '<=', '2023-03-01 23:59:59');
gr.setLimit(10);
gr.orderByDesc('sys_created_on');
gr.query();
while (gr.next()) {
gs.print('Number: ' + gr.getValue('number') +
', Caller: ' + gr.getDisplayValue('caller_id') +
', Category: ' + gr.getValue('category'));
}
}