Calculate Incident on hold duration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2021 02:24 PM
The requirement is to calculate the on hold duration of an incident. Whenever an incident state changes from on hold , it should populate the total on hold time in a new field 'On hold Clock'.
The code I am using reflects first on hold time when my incident goes on hold for second time , but its not working for first time, tried putting a delay but did not work.
Before BR
Table: incident, Condition: state changes from On hold
gs.sleep(8000);
var timems =0;
var tm = 0;
var gr=new GlideRecord('metric_instance');
gr.addQuery('id',current.sys_id);
gr.addQuery('value','On Hold');
gr.query();
while(gr.next()){
tm = gr.duration.dateNumericValue();
timems += tm;
}
current.u_on_hold_clock.setDateNumericValue(timems);
Please suggest the modification to make it work in first time itself.
Thanks
Pooja
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2021 03:04 AM
Hello,
Would you mind to share the script used to achieve this goal? I am trying to calculate the On Hold Duration but I am unable to figure on how to do the script.
Thank you,
Andrea Lorenzo Gambadoro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2024 10:28 AM
Hi @Pooja68,
Could you please share the final code here? I have similar requirement