- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2017 02:13 PM
Hi , I was checking "mark_resolved" OOO BR .
Can someone please explain me why calendar_duration and business_duration are different even they are using same function with same
start date and end date and same default calendar.
Business duration is calculation by default calendar but why not calendar_duration ?? we have used same for calculating both.
setResolutionFields();
function setResolutionFields() {
if (current.resolved_by.nil())
current.resolved_by = gs.getUserID();
if (current.resolved_at.nil())
current.resolved_at = gs.nowDateTime();
// Update the fields that indicate the time and duration of this incident from open to resolve.
// Keep track of duration as a glide_duration value (dd hh:mm:ss) and as a pure number of seconds.
// Both calendar time and business time are maintained.
var dataChange = current.opened_at.changes() || current.resolved_at.changes();
var opened = current.opened_at.getDisplayValue();
var resolved = current.resolved_at.getDisplayValue();
if (dataChange || current.business_duration.nil())
current.business_duration = gs.calDateDiff(opened, resolved, false);
if (dataChange || current.business_stc.nil())
current.business_stc = gs.calDateDiff(opened, resolved, true);
if (dataChange || current.calendar_duration.nil())
current.calendar_duration = gs.dateDiff(opened, resolved, false);
if (dataChange || current.calendar_stc.nil())
current.calendar_stc = gs.dateDiff(opened, resolved, true);
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2017 02:19 PM
Actually, they are different function calls. (dateDiff vs calDateDiff).
Business resolve time generally takes into account business hours (that is defined in a calendar/schedule), e.g. if you operate 8 hour days, 3 days would be reflected as 24 hours.
Resolve time is the full value running 24x7 irrespective of a calendar. 3 days would be reflected as 72 hours.
As a side note, the default calendar used is the first one returned in a list.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2017 02:19 PM
Actually, they are different function calls. (dateDiff vs calDateDiff).
Business resolve time generally takes into account business hours (that is defined in a calendar/schedule), e.g. if you operate 8 hour days, 3 days would be reflected as 24 hours.
Resolve time is the full value running 24x7 irrespective of a calendar. 3 days would be reflected as 72 hours.
As a side note, the default calendar used is the first one returned in a list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2017 02:24 PM
Ahh..Yes...
Can you tell me if i need to use schedule in same function then what will be the function ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2017 02:29 PM
If you want to calculate a duration given a schedule, check this out as it has the answer:
if(current.incident_state==6){
var dur = calcDurationSchedule(current.opened_at,current.sys_updated_on);
current.u_resolved_duration= dur;
function calcDurationSchedule(start, end){
// Get the user
var usr =new GlideRecord('sys_user');
usr.get(gs.getUserID());
// Create schedule - pass in the sys_id of your standard work day schedule and pass in the users timezone
var sched =new GlideSchedule('08fcd0830a0a0b2600079f56b1adb9ae',usr.time_zone);
// Get duration based on schedule/timezone
return(sched.duration(start.getGlideObject(), end.getGlideObject()));}