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-15-2017 11:11 PM
Hello Khushboo,
you can use TIME WORKED FIELD
look at this link Timing Functionality - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2017 01:12 AM
There is out of the box Business rule (mark_closed & mark_resolved) available for calculating the business duration .
In this business rule, function calDateDiff is used. it calculates the difference between two dates using the default calendar.
For default calender ,take a look under System Policy> SLA> Calendars.
You can even schedule the calender according to the requirement.
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 start on Mon and closes end of Wed, it would display as 24 hours.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2017 03:26 AM
Hi Tarleen,
How to calculate business duration for a schedule?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2017 03:28 AM
here is a sample script to help you
http://wiki.servicenow.com/index.php?title=Calculate_Duration_Given_a_Schedule