
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2015 04:48 AM
Greetings!
I'm posting because I'm certain this data has to have been collected by some of you out there. I've several ideas in my head, but why reinvent the wheel if I poll you all?
So, what we need is the and that is the current state duration. We are using the standard metrics to pull how long an Incident was in each state in the past, however the data we are missing is being able to report how long Incidents have been sitting in the state they are currently in. Up to this point, we've been exporting the data and creating our own reports to calculate the duration from which the Incident was last updated to the current date, which is less than ideal.
Any thoughts/suggestions on how we can accomplish this?
Many thanks! Amy
Solved! Go to Solution.
- Labels:
-
Analytics and Reports
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2015 11:21 AM
This can come with a bit of load consequence, but its the only way I know of to accomplish it.
We had a similar requirement. They wanted all active calculations to be "as up to date as possible" rather than being null until the calculation completed.
I created a scheduled job that runs every 12 hours. It checks all Metric Instances where calculation_complete = false and updates their duration field. If I were to do it over again, I might add a field to the Metric Definition table which governs whether or not we want the metric instances caught in this script (its essential for some metrics, but not for others).
Scheduled Job: "Update Continuous Duration Metrics"
var inst = new GlideRecord("metric_instance");
inst.addQuery('definition.type','field_value_duration');
inst.addQuery('calculation_complete',false);
inst.query();
while(inst.next()){
inst.duration = gs.dateDiff(inst.start.getDisplayValue(), gs.nowDateTime());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2015 01:50 AM
Hi Amy Lind,
Did you find any solution for this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2015 11:21 AM
This can come with a bit of load consequence, but its the only way I know of to accomplish it.
We had a similar requirement. They wanted all active calculations to be "as up to date as possible" rather than being null until the calculation completed.
I created a scheduled job that runs every 12 hours. It checks all Metric Instances where calculation_complete = false and updates their duration field. If I were to do it over again, I might add a field to the Metric Definition table which governs whether or not we want the metric instances caught in this script (its essential for some metrics, but not for others).
Scheduled Job: "Update Continuous Duration Metrics"
var inst = new GlideRecord("metric_instance");
inst.addQuery('definition.type','field_value_duration');
inst.addQuery('calculation_complete',false);
inst.query();
while(inst.next()){
inst.duration = gs.dateDiff(inst.start.getDisplayValue(), gs.nowDateTime());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2020 08:29 AM
Hi Robert, the above script is very helpful. I scheduled job and tested this out for one of the metrics i created - ticket state duration but am not seeing the business duration or duration field populated after executing the job several times (see screenshot attached). My overall goal is to report on how long a ticket (incident or sc_task) is in the on hold or pending status. Let me know if I'm missing something? Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2020 09:01 AM
Hi Robert, the above script is very helpful. I scheduled job and tested this out for one of the metrics i created - ticket state duration but am not seeing the business duration or duration field populated after executing the job several times (see screenshot attached). My overall goal is to report on how long a ticket (incident or sc_task) is in the on hold or pending status. Let me know if I'm missing something? Thanks in advance.