- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2024 03:41 AM
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2024 07:41 AM - edited 07-29-2024 07:43 AM
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:
{
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2024 09:42 PM
No - unfortunately.. Not got anywhere with it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2024 07:41 AM - edited 07-29-2024 07:43 AM
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:
{
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2024 11:44 PM
Sounds great - will the script work on any table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2024 12:41 PM
Yep it should! As long as it has the "sys_created_on" field and the Assigned to field.