Unable to execute a custom Metric definition to calculate elapsed time until the first assignee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
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)
Issue
The metric is not being captured and no records are being created in the metric_instance table.
Questions
- Has anyone successfully implemented a metric that measures the time until the first population of the Assigned To field?
- Is a Script Calculation metric the correct approach for this requirement, or should I be using a Duration metric instead?
- Is there a better OOTB method to report on "time from creation to first assignment"?
- 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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
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.
