- 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
‎11-05-2020 04:52 PM
You are correct sir. When I first started playing around with it I thought it was calculating correctly but in the subsequent tests it only recorded a duration of 2-4 seconds.
I created the two metrics per your instructions and it's working wonderfully. The only problem is that I need to create a metric instance for the duration for each assignment group that touches it. Right now, there is only once instance being created (the first team).
I tried removing
!mi.metricExists
from the if statement in the 'Time Until Assigned to Fulfiller' script but now I'm getting two records...
I'm not sure what I need to do to remove the duplicate with no duration...
Thanks so much for your help Kieran!
Kevin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2020 02:10 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2023 12:05 PM
@Kieran AnsonWill you please help me?
Using the If statement below, the metric is captured when it is first assigned to a person in a group, as well as every time the incident is reassigned within the group, from one person to another. I'd like to only capture the metric each time the Assigned To changes from empty to having a value, or, when after being assigned to a group, the first time it is assigned to a person.
I am using this If statement because I want it to run for each group it gets assigned to.
//if(start != null && !gs.nil(current.assigned_to)){
I've been playing around with different options but have not figured it out.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2023 11:24 AM
Hi @JR42 ,
We are looking to implement the same, did you find a solution?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2023 01:35 PM
Hi @jonathandrury , I ended up creating an SLA definition for this. It starts a timer anytime the Assigned To field is empty within the group I've specified. Then it's easy to report on, and create notifications around the SLA.