Metric to measure time before unassigned ticket is assigned out
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2014 05:38 AM
Hi Folks,
We are trying to capture the time when a ticket is 'New' or 'Unassigned' with a group, until the assigned_to field is not empty. Played around with a few variations of some current metrics in place without much luck, any ideas?
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2014 06:04 AM
Hello Dan,
Please go through the below wiki link for more info.
http://wiki.servicenow.com/index.php?title=Setting_the_Duration_Field_Value

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2014 06:05 AM
Hi Dan,
Create a metric with type "Script Calculation" and write the below code it will calculate duration between ticket creation and assigned_to.
if (current.assigned_to != '')
{
var value = false;
if (!current.active)
value = true;
createMetrice(value);
}
function createMetrice(value) {
var mi = new MetricInstance(definition, current);
if (mi.metricExists())
return;
var gr = mi.getNewRecord();
gr.field_value = value;
gr.start = current.sys_created_on;
gr.end = gs.nowDateTime();
gr.duration = gs.dateDiff(gr.start.getDisplayValue(), gr.end.getDisplayValue());
gr.calculation_complete = true;
gr.insert();
}
Regards,
Harish.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2014 06:18 AM
Thanks Harish -- this doesn't seem to capture ticket re-assignment to another group. For example if a Ticket is assigned from One group to another -- we want to capture how long it sits there before that new group assigns it to a person.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2014 06:28 AM
Hi Dan,
The above script calculate only once . If you wants to calculate ticket assigned to one person to another person you have to go type field value duration.
Field value duration only will get calculate ticket assigned from one user to another. But it wont calculate assigned_to is from empty to assigned some one.
Regards,
Harish.