- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-05-2020 12:32 PM
My company would like to start reporting on the time it takes (duration) when a ticket is assigned to a group and when it's actually assigned to an individual. I found a post from someone with similar requirements and have modified their metric to closer meet my company's needs...
if (current.assigned_to != '')
{
var value = false;
if (!current.active)
value = true;
createMetrice(value);
}
function createMetrice(value) {
var gr = mi.getNewRecord();
gr.field_value = value;
gr.start = current.sys_updated_on;
gr.end = gs.nowDateTime();
gr.duration = gs.dateDiff(gr.start.getDisplayValue(), gr.end.getDisplayValue());
gr.calculation_complete = true;
gr.insert();
}
The problem that I'm having is that in situations where an incident is assigned to multiple groups, I'm unable to filter which assignment group is associated with the metric instance.
Is there any way I can capture the current assignment group at the time of the metric instance creation?
Thank you!
Kevin
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-05-2020 01:45 PM
This'll need two metrics, one to record assignment group "touches" and one to do the secondary logic.
1. Create a simple assignment group field value duration metric
2. Create a second metric with the below script.
This script checks to find if an assignment metric exists (it should) and returns the time the metric was created. It then creates a metric with the duration calculated on the difference of the assignment group metric start time and the current time.
var mi = new MetricInstance(definition,current);
var start = groupMetric();
if(start != null && !mi.metricExists()){
var gr = mi.getNewRecord();
gr.start = start;
var now = new GlideDateTime();
gr.end = now;
gr.duration = gs.dateDiff(start, now);
gr.value = current.getDisplayValue('assigned_to');
gr.calculation_complete = true;
gr.insert();
}
function groupMetric(){
var metricGR = new GlideRecord('metric_instance');
metricGR.addQuery("definition","06f9db6d2f94a8101c43bed72799b6c2"); //sys_id of assignment group touch metric (store in sys property);
metricGR.addQuery("id",current.sys_id);
metricGR.addQuery("value",current.getDisplayValue("assignment_group"));
metricGR.query();
metricGR.next();
return metricGR.start;
}
Result: We can see the incident was assigned to ACME Support at 21:42:35 and then an assignee allocated at 21:43:15. This shows a 40 second window between the assignment group being set and then actually being assigned to a user to fulfill.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2022 06:55 AM
Hey Kieran,
I found this really useful for a requirement i've received many thanks!
Quick question is there any way i can drill this search result down using the short description?
Trying to use indexof to try and show only tickets with short descriptions using a specific word but so far seems to just ignore it...
this is the amended code
var mi = new MetricInstance(definition,current);
var start = groupMetric();
var d = current.getDisplayValue("short_description");
if(start != null && !mi.metricExists() && d.indexOf('Phish') >=0){
any ideas?
Thank you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 06:41 AM
Hiya Sam,
Are you only wanting a metric created if the description contains "phish" in some place?
If so, the following should work? (I think, I've not tested):
var mi = new MetricInstance(definition,current);
var start = groupMetric();
var d = current.getValue("short_description");
if(start != null && !mi.metricExists() && d.indexOf('Phish') > -1){
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2022 06:51 AM
Hi Kieran,
Thanks for getting back to me really appreciate the response.
I actually ended up using your method to create the 2 metrics and then created a report on Time Until Assigned as the definition where i could then filter the results
thanks again super useful stuff!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-05-2020 02:20 PM
Hey Kieran,
It's set to the 'Assigned to' field...
You can see when I enable the column in the report for Duration (mi_duration) that I still get the duration as well as the assignment group.
The durations appear to be correct. I only waited a few seconds between each assigned_to change. The very bottom one was me assigning a ticket directly to a person within that assignment group so the duration is 0.
Kevin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2021 10:59 AM