how to SUM of multiple duration field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2022 05:39 AM
Hi Team,
In metrics definition I am getting multiple record when I am changing same value in multiple time (changing value awaiting caller again and again)
So now I want to sum these duration and have to store in custom field of incident,
I am trying with below code but not get success
var duration = new GlideDuration(0);
var mi = new GlideRecord("metric_instance");
mi.addQuery("id", current.sys_id);
mi.addQuery("definition", "fc47ec1d2f1341105d0d56e62799b64e");
mi.addQuery("value", "Awaiting Caller");
mi.query();
mi.getRowCount();
// while(mi.next()){
var dur = new GlideDuration();
dur.setValue(mi.getValue('duration'));
duration = duration.add(dur);
// }
current.u_pause_duration= duration.getDisplayValue();
current.u_total_hour=duration;
gs.addInfoMessage(duration.getDisplayValue());
gs.addInfoMessage(mi.getRowCount());
current.update();
So how can we achieve it please help me here?
please help me here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2022 12:10 PM
Hi,
Try below code
var dur = new DurationCalculator();
dur =mi.duration.dateNumericValue();
mi.duration.setDateNumericValue(dur);
Hope this can help you!