Substract "On Hold" Time from Duration Field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2022 09:21 AM
Hello everyone.
In the company came this request.
Knowing that the "duration" field calculates the TOTAL lifetime of a ticket, it's necessary to subtract the time in which a ticket is "on hold" from the total calculation of the duration field (calendar_duration).
This in order to know the effective time of the ticket.
NOTE: We are not looking for the total calculation to appear within the report but within the field.
We would appreciate your help.
Best regards.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2022 09:32 AM
Hi Diego,
Unless customized there does not seems to be an alternate approach.
Suggestion would be if you have SLA to report on Task SLA table & look for fields like Business Elapsed Time as this will exclude Pause duration. Assuming you have SLA pausing when ticket is placed OnHold
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2022 10:57 AM
Thank you very much Jaspal.
The SLAs are configured in this way.
But Business Elapsed Time doesn't substract the time of the total lifetime of the ticket.
It is necessary to subtract the time that the ticket has been "on hold" in the "Duration" field to facilitate the work of the resolver users.
Our theory is to modify the BR "Mark on Hold" since it is the one that populates the "duration" field.
And this is the script:
setClosureFields();
function setClosureFields() {
// incident_state is Closed so
// 1. mark the task as inactive
// 2. set the closed by to current user if not supplied
// 3. set the closed time to now if not supplied
current.active = false;
if (current.closed_by.nil())
current.closed_by = gs.getUserID();
if (current.closed_at.nil())
current.closed_at = gs.nowDateTime();
// Update the fields that indicate the time/duration of the incident from open to close.
// Keep track of duration as a glide_duration value (dd hh:mm:ss) and as a pure number of seconds.
// Both calendar time and business time are maintained.
var dataChange = current.opened_at.changes() || (current.closed_at.changes() && !current.isValidField("resolved_at"));
var opened = current.opened_at.getDisplayValue();
var closed = current.closed_at.getDisplayValue();
if (dataChange || current.business_duration.nil())
current.business_duration = gs.calDateDiff(opened, closed, false);
if (dataChange || current.business_stc.nil())
current.business_stc = gs.calDateDiff(opened, closed, true);
if (dataChange || current.calendar_duration.nil())
current.calendar_duration = gs.dateDiff(opened, closed, false);
if (dataChange || current.calendar_stc.nil())
current.calendar_stc = gs.dateDiff(opened, closed, true);
}
As you mention in your answer, it could be customized, if there is any way to do it and if you share it with us, we would greatly appreciate it.
Best regards