Calculate total 'on hold' duration of incident and add it as a custom field in the form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 06:22 AM
Hi,
We have a requirement to display the total time spent in 'on hold' state of an incident and display its value as a custom field in the incident form. I tried creating a 'duration' type field with calculated value using below script, but it does not seem to display the total duration calculated. However, when i use the same script on a 'string' type field, it populates the value. Can someone please help in identifying why 'duration' type field isn't displaying the value or where I am going wrong and how can I fix this. The duration is ideally required to be populated in day/hour/min format so its easily understandable by users.
Script :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 06:46 AM
Hi @MaryJohn
There is a field on the SLA table which capture the on-hold duration and total onhold, try to use that.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 07:09 AM
Thanks for replying @Dr Atul G- LNG ,
I tried to find the 'total onhold' field in sla table (both task sla and incident sla table), i am unable to find it. Could you please elaborate. Also, any idea why my code is not adding the total duration to the custom field in incident form i created?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 07:15 AM
Thanks for replying @Dr Atul G- LNG
I tried to find ' total onhold' field as you suggested in both incident sla and task sla tables, but unable to find it. Could you please elaborate let me know where i can find it.
Also, any idea why my code is not displaying the total value in the custom field I created?
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 08:15 AM
Thanks for replying @Dr Atul G- LNG,
I tried to find 'total onhold' field on both incident SLA and task SLA tables, but I am unable to find it.
Could you please elaborate. Also, any idea why my code is not displaying the total duration in the custom field I created, are there any corrections required?