Updating SLA Planned End Time when Due Date Changes

Sue Frost
Giga Guru

I have a request to update the Planned End Time on the SLA when the Due Date on the Case (aka Task) changes. Authorized users are able to update the Due Date.

(Background - if the due date on a case is extended, then the SLA may breach because the planned end time does not update.)

I was able to location a HI article which suggested a solution:

- add a reset condition of Active = True and Due Date changes

- add a custom Duration Type with the following script

// Perform relative duration calculation using the 'calculator' variable (which is a DurationCalculator object)

var endDateTime;

if (current.getRecordClassName() == 'task_sla') {

      endDateTime = current.task.due_date;

} else {

      endDateTime = current.due_date;

}

calculator.calcScheduleDuration(calculator.startDateTime, endDateTime);

Article link: https://hi.service-now.com/kb_view_customer.do?sysparm_article=KB0536464&sysparm_topic=Known+Error+D...

What I'm seeing now is the exact problem that this HI article was designed to fix - the start and end date/times are being set to the same time:

SLA Start End Times.png

Interestingly, if the due date is actually overridden, the original SLA (as seen above) is completed and the new one shows correct start and end times:

SLA Start End Times -2 .png

Since I can't assume that a due date WILL be overriden, I need to find a way to correctly create the original SLA.

On a related thread: SLA Status on Reset - Complete vs. Cancelled I also need a way to identify the completed SLA so that it can be excluded from reporting.

Thanks in advance for suggestions and help.

1 ACCEPTED SOLUTION

Sue Frost
Giga Guru

Replying back to provide our final solution. Hopefully someone else will find this helpful. Here's what I ended up doing to solve this issue and fulfill the request.



Original Request


When the Due Date is overridden on the CASE table (extended from Task), the Resolution SLA should reflect the new Due Date as the Planned End Date. The Resolution SLA should not breach until the Due Date is reached.



Solution


  • added Relative Duration "Based on Due Date" which calculates Planned End Time / timings on SLA based on the Due Date on the Case. (uses code listed in original post, above.)
  • added Business Rule "Set Due Date Override flag" to set Due Date Override flag to 'true' when the Due Date field changes. (Due Date Override can't be made a dependent field of Due Date - that option is only available to Choice and Reference fields and Due Date Override is a true/false field.)
  • updated all existing Resolution SLAs to add a new start condition of "Due Date Override = false": (see attachment)
  • created new "Case Resolution - Due Date / Résolution de dossier - Modification d'échéance" SLA to:

                            - start when Due Date Override is true & case is open


                            - stop when case is closed


                            - duration type is "Based on Due Date"


  • copied existing task sla cleanup business rule to "Task SLA Cleanup - Due Date" which will delete any in-progress resolution SLAs when the due date changes.


Notes


  • SLAs not driven off a user-specified duration do not have a Pause condition. It's not applicable)
  • A Reset condition of <field> CHANGES causes the original SLA to complete, leading to duplicate completed SLAs which can be an issue for reporting.



View solution in original post

9 REPLIES 9

Sue Frost
Giga Guru

Replying back to provide our final solution. Hopefully someone else will find this helpful. Here's what I ended up doing to solve this issue and fulfill the request.



Original Request


When the Due Date is overridden on the CASE table (extended from Task), the Resolution SLA should reflect the new Due Date as the Planned End Date. The Resolution SLA should not breach until the Due Date is reached.



Solution


  • added Relative Duration "Based on Due Date" which calculates Planned End Time / timings on SLA based on the Due Date on the Case. (uses code listed in original post, above.)
  • added Business Rule "Set Due Date Override flag" to set Due Date Override flag to 'true' when the Due Date field changes. (Due Date Override can't be made a dependent field of Due Date - that option is only available to Choice and Reference fields and Due Date Override is a true/false field.)
  • updated all existing Resolution SLAs to add a new start condition of "Due Date Override = false": (see attachment)
  • created new "Case Resolution - Due Date / Résolution de dossier - Modification d'échéance" SLA to:

                            - start when Due Date Override is true & case is open


                            - stop when case is closed


                            - duration type is "Based on Due Date"


  • copied existing task sla cleanup business rule to "Task SLA Cleanup - Due Date" which will delete any in-progress resolution SLAs when the due date changes.


Notes


  • SLAs not driven off a user-specified duration do not have a Pause condition. It's not applicable)
  • A Reset condition of <field> CHANGES causes the original SLA to complete, leading to duplicate completed SLAs which can be an issue for reporting.



Good day,



I am using the following relative duration script to calculate from due_date on catalog tasks, however it is not setting an SLA Duration property for my "business elapsed percentage" to calculate against. Do you know how to perform this in script?



// 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;  






Thank you


hi Shane,



did you get fix for this issue?/


Unfortunately I cannot recall! My apologies Padmini.