Due Date SLA.

Kusuma2
Kilo Guru

Hi Team,

I need to set the Sla duration time based upon the due date field which is present on the Request item form.

Indetail:

I have field on the Request item form. So based upon this date the duration of sla need to set.

Due date (req item form) should match the duration of Sla.

Thanks,

Ajay.

15 REPLIES 15

Hello Navdeep,



I pasted the same script but the Breach Time of the Task SLA is not setting to the value in the "Due date" .Please refer the screen shot and inform me if I have done any mistake.


find_real_file.png


find_real_file.png


Here the due date is a field on req item form which is getting populated from the workflow.


In the above screen shot the due date:25 july


                                                                                            Breach time:20 july.


                                                                                                Actual elapsed time:25 july.


I did not understand the difference between the breach time and the Actual elapsed time..


Could you please share the screen shot of your SLA definition?


find_real_file.png


Thanks for your quick response.


It works on my developer instance. Try to print logs of due date in Relative Duration Script.


Is there anything in your workflow or in a business rule that is changing the due date? Due date-based SLAs in Jakarta will not recalculate by default when the due date changes. If you want the SLA to update, then you need to put in a business rule on the sc_req_item table that will reset the planned_end_time to match the due date on any SLA where the definition is based on task due date.



Here is what I have done for this:


When to run: after (or async)


Update: true


Conditions: Due date changes AND due date is not empty


Script:


(function executeRule(current, previous /*null when async*/) {




// Check for task SLAs configured to run on due date. Need to change the end time in order to recalculate.



// Get running task SLAs



var ts = new GlideRecord('task_sla');


ts.addActiveQuery();


ts.addQuery('sla.duration_type','5d3bf3e5eb5322002a7a666cd206fe8e'); // Breach on Due Date


ts.addQuery('task',current.getUniqueValue()); // Look for any running SLAs for the current task



ts.query();



while (ts.next()){



// Reset the end_time on the SLA to match the current due date


ts.setValue('planned_end_time',current.getValue('due_date'));


ts.update();


}




})(current, previous);



Note that there is no "history" to show that the SLA was reset. It may be better to cancel the running SLA and let the system insert a new one. You definitely want to audit due date changes, otherwise users can just change the due date to avoid an SLA breach. There may be legitimate reasons for changing the date, though.



Let me know if that helps.



Thanks,


Nick



***EDIT***


Updated the script above to include the current task in the task_sla query. Otherwise, you get ANY active task SLA that is based on due date.