- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2022 03:52 AM
Hi There,
is there a possibility to measure the time a tickets spends in a specific state? I would like to have an average time tickets of a specific service are on hold or work in progress. How would I do this?
Best
Inga
Solved! Go to Solution.
- Labels:
-
Reporting

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2022 06:25 AM
Hello
Yes, this is possible with Metrics of Type script calculation. PFB screen shot -
Code -
var s = current.incident_state;
if (s == 2) // if state is In Progress
createMetric();
function createMetric() {
var mi = new MetricInstance(definition, current);
if (mi.metricExists())
return;
var gr = mi.getNewRecord();
gr.value = current.incident_state.getDisplayValue();
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();
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Akshay Kangankar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2022 06:25 AM
Hello
Yes, this is possible with Metrics of Type script calculation. PFB screen shot -
Code -
var s = current.incident_state;
if (s == 2) // if state is In Progress
createMetric();
function createMetric() {
var mi = new MetricInstance(definition, current);
if (mi.metricExists())
return;
var gr = mi.getNewRecord();
gr.value = current.incident_state.getDisplayValue();
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();
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Akshay Kangankar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2022 01:28 AM
Hello
Glad my answered is helped you, is your requirement is completed with my answer. If Yes then please mark my answer Correct as well. It will use for other community members.
If not let us know your issue so we can help you.
Thanks
Akshay Kangankar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2023 12:27 PM
Akshay - I'm wondering if I can use this to calculate the length of time a RITM is open. We have RITMs with more than one task and we are trying to understand the length of time the entire RITM is open and secondly to understand how long the SCTasks associated with a RITM are open. We are currently on UTAH. Di