Unable to execute a custom Metric definition to calculate elapsed time until the first assignee

AndreTella
Tera Contributor

Hi everyone,

I'm trying to build a custom metric in ServiceNow to measure the following KPI:

Average time from Incident creation until the Incident is assigned to an analyst (Assigned To field).

Specifically, I want to calculate how long an Incident remains with Assigned To = Empty from the time it is created until the first time it is assigned to a user.

I created a Metric Definition with:

  • Table: Incident
  • Type: Script Calculation
  • Active: True

And I'm using a script (attached)

AndreTella_0-1791399796080.png

 

Issue

The metric is not being captured and no records are being created in the metric_instance table.

 

Questions

  1. Has anyone successfully implemented a metric that measures the time until the first population of the Assigned To field?
  2. Is a Script Calculation metric the correct approach for this requirement, or should I be using a Duration metric instead?
  3. Is there a better OOTB method to report on "time from creation to first assignment"?
  4. Are there any special considerations with MetricInstance, metricExists(), or changesToNotNil() when used in Metric Definitions?

Any examples or working configurations would be greatly appreciated.

Thanks!

 
2 REPLIES 2

Kieran Anson
Kilo Patron

Your metric isn't firing because it's waiting for the field you've selected to change. Active wont change until the incident is closed, so your script won't evaluate. 

 

Is field duration insufficient for what you need? Why isn't an SLA/OLA being used?

Got it, Kieran.
But I wasn't focusing on the "Assigned to" field? Why it only will be triggered when the Incident is closed? Just curious...

I've created an SLA as a Plan B, and it worked as expected.