Unassigned Duration per Assignment Group - Metric Definition values

Elizabeth10
Tera Contributor

I understand from a servicenow video, that this Metric Definition: Unassigned Duration per Assignment Group is OOTB. But I can't see it in our instances. Can someone please let me know the values set for all fields/scripts etc for this metric definition, so I can create it myself? 

1 ACCEPTED SOLUTION

I was able to figure it out! This community post reply by Harish Murikina was very helpful. https://www.servicenow.com/community/itsm-forum/metric-to-measure-time-before-unassigned-ticket-is-a... . You just create a new metric definition called "Unassigned Duration" or something like that. Use whatever table you are reporting on, select "Assigned to" as the field. Then, select Script Calculation as the type and paste the following script:

 

 

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();

}

View solution in original post

8 REPLIES 8

No - unfortunately.. Not got anywhere with it

I was able to figure it out! This community post reply by Harish Murikina was very helpful. https://www.servicenow.com/community/itsm-forum/metric-to-measure-time-before-unassigned-ticket-is-a... . You just create a new metric definition called "Unassigned Duration" or something like that. Use whatever table you are reporting on, select "Assigned to" as the field. Then, select Script Calculation as the type and paste the following script:

 

 

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();

}

Sounds great - will the script work on any table? 

Yep it should! As long as it has the "sys_created_on" field and the Assigned to field.