Skip to content

Created a script to get the count of incidents by priority under each category. #1617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Get the count of Incidents by Category and then by Priority.

var incCATGR = new GlideAggregate('incident');
incCATGR.addAggregate('COUNT', 'category');
incCATGR.orderBy('category');
incCATGR.query();

while (incCATGR.next()) {
var cat = incCATGR.category;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't use this variable, and additionally should use getters to avoid relying on GlideElement casting

gs.print("Category Name: " +incCATGR.category.getDisplayValue() + ' --> ' + incCATGR.getAggregate('COUNT', 'category'));
var incPriorityGR = new GlideAggregate('incident');
incPriorityGR.addQuery('category', incCATGR.category);
incPriorityGR.addAggregate('COUNT', 'priority');
incPriorityGR.orderBy('priority');
incPriorityGR.query();

while(incPriorityGR.next()){
gs.print("Priority-" +incPriorityGR.priority + " = " +incPriorityGR.getAggregate('COUNT', 'priority'));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Purpose: This piece of code will be helpful to get the count of incidents by Priority under each Category.

Sample Output:
==============
*** Script: Category Name: --> 4
*** Script: Priority-1 = 2
*** Script: Priority-2 = 1
*** Script: Priority-4 = 1
*** Script: Category Name: Database --> 3
*** Script: Priority-1 = 1
*** Script: Priority-4 = 1
*** Script: Priority-5 = 1
*** Script: Category Name: Hardware --> 10
*** Script: Priority-1 = 5
*** Script: Priority-3 = 2
*** Script: Priority-5 = 3
*** Script: Category Name: Inquiry / Help --> 84
*** Script: Priority-1 = 10
*** Script: Priority-2 = 2
*** Script: Priority-3 = 13
*** Script: Priority-4 = 17
*** Script: Priority-5 = 42
*** Script: Category Name: Network --> 12
*** Script: Priority-1 = 2
*** Script: Priority-2 = 2
*** Script: Priority-3 = 1
*** Script: Priority-4 = 2
*** Script: Priority-5 = 5
*** Script: Category Name: Software --> 131
*** Script: Priority-1 = 15
*** Script: Priority-2 = 15
*** Script: Priority-3 = 23
*** Script: Priority-4 = 28
*** Script: Priority-5 = 50



Loading