Does anyone know how to get a list of incident or request categories that have not been used?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2017 12:05 PM
I can get a count of categories that have been used and how many times but I don't know how to get a list of categories that have not been used, does anyone know how to do this?
- Labels:
-
Reporting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2017 08:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2017 11:29 AM
ok, seem good doesnt it?
if you want to see all category counts change set variable onlyZero = 0
if you dont want the lines in between push the values to an array an print it in the last line
If its ok, please mark as answered...
//Options
var onlyZero = 0 //set to 0 to display all categorie counts.
var table = 'incident';
//backgroundscript
var gr = new GlideRecord('sys_choice');
var output = [];
output.push('Category|Count');
gr.addEncodedQuery("name="+ table +"^element=category^language=en^inactive=false");
gr.orderBy('value');
gr.query();
while (gr.next()) {
var count = new GlideAggregate('incident');
count.addQuery('category', gr.value);
count.addAggregate('COUNT');
count.query();
var catCount = 0;
if (count.next())
catCount = count.getAggregate('COUNT');
if (catCount == 0 || !onlyZero)
output.push(gr.value + '|' + catCount);
}
gs.print('\n' + output.join('\n'));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2017 12:20 PM
Hi Arnoud,
Thank you for your time. The two categories in the script output have been used thousands of times or am I reading it wrong? Some of our categories have 4 levels, a parent and 4 subcategories does that matter?
Example: Hardware > Telephony > Cisco > PBX > Failure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2017 12:28 PM
I don't know the structure and quantity of your data. Good luck.