Script for resolution time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â09-08-2023 12:00 AM - edited â09-08-2023 01:22 AM
I want to write a script for query all Incidents where the State is "Resolved" or "Closed" and
calculate the duration between opened_at and resolved_at value. Write the result
to the "Resolution time" field. Please guide me for writing script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â09-08-2023 12:07 AM
@Viri you can create a metric definition on incident table which will calculate auto time duration as per created definition.
Hope it will help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â09-08-2023 01:07 AM
@Abhay Kumar1 I wanted to try writing script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â09-09-2023 12:24 AM
@Viri do let me know you need working script I can probably help you as I am written few and it's working fine.
Even you can populate previous all incident duration to fetch from Audit table as one time activity.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â09-08-2023 05:29 AM
Hi! A good approach will be to post your code here that you have tried out. The community is then here to help you out. To begin, one approach could be as follows:
1. Get all the incidents with the filter - GlideRecord API
2. Calculate the duration (difference) between the opened and resolved. GlideDateTime API (.getNumericValue)
3. Set the value on the field - GlideRecord API [.setValue()]