Calculating the Planned end time of an SLA in the 2011 SLA Engine
In the 2011 SLA Engine, the Planned end time of an SLA needs to be calculated as follows:
When the task_sla record is first created
- When the task_sla transitions from a Paused condition back to In Progress
The calculation is done in the TaskSLA script include in the _recalculateEndTime function. This function uses the DurationCalculator script include, which provides a variety of utilities for doing date arithmetic while factoring in schedules.
Keep in mind that the concept of business time is dependent on a schedule to define the work hours in question. In the absence of a schedule, the business time is the same as the actual time, calculated on a 24-hour day.
The calculation is straightforward, and is dependent on five values, all of which are copied into the task_sla record:
The start_time of the SLA as specified in the SLA Definition.
The schedule – Default choices are either to use the schedule specified in the SLA definition or to use the schedule from the CI associated to the task.
The time zone – There are five possible default selections for the tim zone, but this value must not be null for calculations. If the selection is null, the time zone is defaulted to the system timezone.
The duration – This can be fixed (User defined) or scripted (Relative duration). If there is a schedule, the duration is business time.
Any accumulated pause duration – This value is relevant only when transitioning from a Paused condition back to In Progress).
All of the values are fixed except the schedule, which is a reference value to a Schedule (cmn_schedule) and its Schedule Entries (cmn_schedule_span), and a Relative duration (which is scripted).
In simple terms, the planned_end_time is just the start_time with the actual duration added to it. The trick is in applying the adjustments for the schedule and the timezone in order to convert a business duration to an actual duration.
Common causes of errors
The most common causes of an error in the Planned end time are:
- A relative duration script error
- A schedule problem such as an incorrect schedule entry
If there is a question about the Planned end time calculated for any particular SLA, for troubleshooting:
- Check the Planned end time value by calculating it by hand.
- If the hand-calculated value does not check out and there is not a relative duration, check the schedule and the schedule entries.