How to sum of duration field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2022 02:10 AM
Hi Team,
We have have custom choice field called substate which has different value.I have defined metrics to run on this field. This is for Incident table
the substate value is caller, vendor, customer.
so I have to calculate time for each value means how much time ticket was in particular substate choice value.
but when I changing value to caller and again changed to caller so it's is creating multiple record in metric instance for caller value .
So I have to sum of all duration and have to populate in incident custom string field.
for that I have written business rule but I faild to get result
please help me here. I am stuck here from last 3 days .
Please can you help me here with some script .?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2022 05:55 AM
Hi,
Try below code
var dur ='';
var gr - new GlideRecord('metric_instance');
gr.addQuery('id',current.getValue('id');
gr.addQuery('defination','REPLACE_SYS_ID');
gr.addQuery('value','Caller');
gr.query();
while(gr.next()){
dur = new DurationCalculator();
dur =gr.duration.dateNumericValue();
}
var tab = new GlideRecord('table_name');
tab.get(current.getValue('id');
tab.u_substate.setDateNumericValue(dur);
tab.update();
Hope this can help you!