- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2023 02:30 AM
Hi All,
I have a task to get the time between - when the ticket was created and the first assignee. I have created metrics for the same. I need help with the script which will exclude all the other assignees except the first and show me the time in metric definition.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2023 02:45 AM
Hi,
// variables available
// current: GlideRecord - target incident
// definition: GlideRecord - (this row)
if (current.assigned_to) {
value = current.assigned_to;
createMetric(value);
}
function createMetric(value) {
var mi = new MetricInstance(definition, current);
if (mi.metricExists())
return;
var gr = mi.getNewRecord();
gr.field_value = value;
gr.field = "assigned_to";
gr.start = current.sys_created_on;
gr.end = current.sys_updated_on;
gr.duration = gs.dateDiff(gr.start.getDisplayValue(), gr.end.getDisplayValue());
gr.calculation_complete = true;
gr.insert();
}
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2023 07:23 AM
Hi @swapnil15
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2023 07:23 AM
Thanks for the script @Saurabh Gupta .
If a user changes the assignee to a blank/ empty and again assigns a user the script will give the wrong time. How to control this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2023 07:26 AM
Hi @swapnil15
It will only create one record in metric instance.
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2023 07:45 AM
hi @Saurabh Gupta ,
I tried making changes to the assigned_to multiple times, and multiple records were recorded in the metrics for the above script. PFA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2023 07:46 AM
Hi,
Share the metric definition record please?
Thanks and Regards,
Saurabh Gupta