- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2019 12:49 AM
All,
i am trying to put a metric together, which is recording all the workgroups a change has been assigned to.
I was using a script by Dennis R from this community called Incident Touched as basis, for unknown reasons it is refusing to work for me.
I have created the following metric definition:
And used the script from Dennis R which is working fine in incident management:
/**
* Creates a metric to record that an assignment group touched an incident.
* Does not create duplicate metrics if an incident is assigned to an
* assignment group multiple times.
*
* Parameters
* These parameters are passed into all metric definition scripts.
*
* current
* The current record that triggered the metric definition
*
* definition
* The metric definition being triggered
*
* mi
* A MetricInstance object (see the MetricInstance script include for more
* information and documentation). I'm not a big fan of using the mi object
* because it doesn't really contain complete functionality or the ability
* to customize metrics to the extent that a custom script normally
* demands.
*
* Created by Dennis R
* 2017-08-16: Initial creation
*/
(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.addQuery('value', current.getDisplayValue('assignment_group'));
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);
Anyone having a clue, why this is not working in change??
Cheers
Michael
Solved! Go to Solution.
- Labels:
-
Reporting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2019 09:30 AM
Are you reporting on the incident.assignment group? You need to report on the metric.value (which has all the various groups)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2019 09:58 AM
Hi Michael (and Adam!), I'm trying to do the exact same thing - use Dennis's script/metric but on change request but am not having much luck.
As you have got this working could you please send me a screenshot of the report conditions you are running?
Did you do everything the same from Dennis' post but create the metric definition on the change request table (as I have done)?
Many thanks for any help.