Set up an SLA for a Task's Due Date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2011 11:54 AM
I would like to create an SLA Definition that sets the Task SLA Planned end time equal to the Due date of the Task its attached to. I have already tried a Task SLA Business Rule that manually overrides the Planned end time value, but it appears the SLA is already calculating by the time I override it -- so altering the Planned end time has no effect. I have also tried to create a custom Relative Duration called "Use due date". It works most of the time, but unpredictably produces Planned end time values that are much sooner than the Task's Due date. Here is the script for the custom Relative Duration:
var d = current.task.due_date.getGlideObject(); var s = (d.getNumericValue() - (new GlideDateTime()).getNumericValue()) / 1000; calculator.calcDuration(s); current.planned_end_time = d;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2012 09:35 AM
Thanks for the update today. I have been watching this because we are looking at performing the same function. Perfect timing.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2012 02:53 AM
I should add - I consider this approach as a workaround (it's inelegant and unclear to have to look at what 'current' is, for a start), and there should probably be a cleaner and neater way of doing this.
([Updated to add] - The underlying cause of your problems - as outlined to me via INT1946184 - are that you're relying upon current always being the task_sla record. Whereas with the June 11 code it often isn't.)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2012 07:35 PM
I'm having a hard time following this thread. Is there any simple solution for this that doesn't involve hacking out-of-box code? Ideally, I'd like to be able to define a relative duration option for 'Task Due date'. Seems like there should be a defined relative duration script for this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2012 02:24 AM
mark.stanger
There's nothing proposed here (not by me, anyway) that requires 'hacking' out-of-box code, though all solutions do currently require making an assumption about how to find your 'task' record (the "relative duration" API doesn't currently specify a way, or make any guarantee on what 'current' is to be.)
Define a relative duration script, that looks carefully at what current is, before assuming which object is the task record with the due_date field.
It should probably look something like this:
// Perform relative duration calculation using the 'calculator' variable (which is a DurationCalculator object)
var baseTable = new TableUtils(current.getRecordClassName()).getAbsoluteBase();
if (baseTable == 'task')
myTask = current;
else if (baseTable == 'task_sla')
myTask = current.task;
var dueBy = myTask.due_date.getGlideObject(); // due_date - a glide_date_time field on our associated Task record
calculator.endDateTime = dueBy;
calculator.seconds = ((dueBy.getNumericValue() - calculator.startDateTime.getNumericValue()) / 1000);
calculator.totalSeconds = calculator.seconds;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2012 05:15 AM
Told you I was having a hard time following the thread :). I'll give that a try and see how it goes!