Business duration is not getting calculated correctly.business rule used for calculation is
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2017 10:45 PM
if (current.state == 7) {
// incident state is closed so
// 1. mark the task as inactive
// 2. set the closed by to current user if not supplied
// 3. set the closed time to now if not supplied
current.active = false;
if (current.closed_by.nil())
current.closed_by = gs.getUserID();
if (current.closed_at.nil())
current.closed_at = gs.nowDateTime();
// now we want to update the fields that indicate the time
// or duration of this incident from open to close. We 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
current.business_duration =
gs.calDateDiff(
current.opened_at.getDisplayValue(),
current.u_resolved.getDisplayValue(),
false);
current.business_stc =
gs.calDateDiff(
current.opened_at.getDisplayValue(),
current.u_resolved.getDisplayValue(),
true);
current.calendar_duration =
gs.dateDiff(
current.opened_at.getDisplayValue(),
current.u_resolved.getDisplayValue(),
false);
current.calendar_stc =
gs.dateDiff(
current.opened_at.getDisplayValue(),
current.u_resolved.getDisplayValue(),
true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2017 03:39 AM
Please refer to this link for creating schedules -
Using Schedules - ServiceNow Wiki
Please share the respective resolved date , opened date & business duration values which according to you is getting calculated wrongly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2017 03:55 AM
As already mentioned, Business duration is the time from open to closure, in regards to the primary SLA calendar. So if your Calendar is 8 hour day Mon-Fri, and a incident opens on Mon and closes on end of Wed, it would display as 1 day (24 hours).
eg :
opened_at : 18/01/2017
resolved_at : 21/01/2017
then the Business duration : 1 day
& Duration : 3 days