- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2017 01:39 AM
Hello all,
I am trying to create a widget on PA, which measures the number of incident tickets inflow to a certain assignment group. As a ticket might get reassigned to different assignment groups few times before resolved, I will need to get the number of tickets inflow from Incident metric table using "new value" field.
I did follow the steps in How can I create a breakdown by task type on the Time Card table? but need help with the script.
How should I modify the script below to capture Definition = Assignment Group and value that captured in manual breakdown must not duplicate?
Ex: ServiceNow Admin appears two times. The script below should capture only one "ServiceNow Admin" to the manual breakdown table.
var table = 'task';
var col = 'sys_class_name';
var breakdown = '[sys_id of manual breakdown]';
gs.log('Collection of Task types started');
//do not modify:
(function(table, col, breakdown) {
var ga = new GlideAggregate(table);
ga.addAggregate('COUNT', col);
ga.query();
while(ga.next()) {
var value = ga.getDisplayValue(col);
var gr = new GlideRecord('pa_manual_breakdowns');
gr.addQuery('breakdown', breakdown);
gr.addQuery('value', value);
gr.query();
if(!gr.next()) {
gr = new GlideRecord('pa_manual_breakdowns');
gr.initialize();
gr.setValue('breakdown', breakdown);
gr.setValue('value', value);
gr.insert();
gr.close();
}
}
ga.close();
gs.log('Collection of Task types finished');
}) (table, col, breakdown);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2017 07:58 AM
Your mapping is to mi_value, change this to mi_field_value (this contains the group sys_id)
Also, try not using duplicate breakdowns I would recommend
Original correct answer:
You can just use your normal Assignment group Breakdown, and create the breakdown mapping to mi_field_value No scripting should be necessary
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2017 10:34 AM
Awesome Arnoud!!!
You are a star!! works as expected now!
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2017 11:43 AM
Good, glad it works!