How to build a report from CSM case metrics
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2023 02:17 PM
I am trying to create a metric definition in CSM for cases that have ever been assigned to a specific assignment group. I copied this from a Incident Touched by Assignment Group script I found and set it up within the Customer Service application and pointed the table to sn_customerservice_case. But I can't seem to get it to pull any data. I'm sure there is something simple I'm missing in the definition. Does anyone have any helpful tips and can help me get this fixed and a report built off of it?
(function calculateMetric(current, definition, mi) {
// Check to see if a metric instance already exists for this ticket
// assigned to this assignment group
var grMetric = new GlideRecord('metric_instance');
grMetric.addQuery('id', current.getValue('sys_id'));
grMetric.addQuery('definition', definition.getValue('sys_id'));
grMetric.addQuery('value', current.getDisplayValue('assignment_group'));
grMetric.query();
if (grMetric.hasNext()) {
// If so, then this ticket has already been counted for this assignment
// group and there's no need to do anything.
} else {
// If not, create one
var now = new GlideDateTime();
var instant = new GlideDuration(0);
grMetric = new GlideRecord('metric_instance');
grMetric.initialize();
grMetric.setValue('table', current.getRecordClassName());
grMetric.setValue('id', current.getValue('sys_id'));
grMetric.setValue('definition', definition.getValue('sys_id'));
grMetric.setValue('field', definition.getValue('field'));
grMetric.setValue('value', current.getDisplayValue('assignment_group'));
grMetric.setValue('u_value_two', current.getDisplayValue('assigned_to'));
grMetric.setValue('duration', instant);
grMetric.setValue('business_duration', instant);
grMetric.setValue('calculation_complete', true);
grMetric.setValue('start', now);
grMetric.setValue('end', now);
grMetric.insert();
}
})(current, definition, mi);
Labels:
- Labels:
-
Customer Service Management
0 REPLIES 0