- 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:51 AM
Hi @swapnil15
In my PDI it is working as expected-
Below is the part of code, which will make sure it will run only on first assignment.
var mi = new MetricInstance(definition, current);
if (mi.metricExists())
return;
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2023 07:59 AM - edited ‎12-18-2023 08:00 AM
Hi @Saurabh Gupta ,
Apology, I have kept the type as field value duration hence the issue.
It works well as expected now, thanks a million.