Script for resolution time

Viri
Tera Contributor

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 

4 REPLIES 4

Abhay Kumar1
Giga Sage

@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.

@Abhay Kumar1 I wanted to try writing script

@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

Robin John
Kilo Sage

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()]