Dynamically setting SLA Duration

lisavb1970
Kilo Contributor

I have a requirement to set the SLA Duration by a Target Date field (u_target_date) from a Problem ticket.

6 REPLIES 6

Which timezone do you want to use for the hours?



The second part of your script might not be necessary (calcScheduleDuration method sets also planned end time and seconds for SLA, no need to additionally call calcRelativeDueDate). If you try this code, you will end up having SLA planned end time set to the "endDateTime". You might want to play around the time and the timezone as in this way, it will be stored into database as 17:00, but actually user might see then different time.



var endDateTime = new GlideDateTime(current.variables.requested_date + ' 17:00:00');


calculator.calcScheduleDuration(calculator.startDateTime, endDateTime);



I would also propose to use "calculator.startDateTime" instead of "startDateTime" as this might cause incorrect calculations of SLA, but I did not verified that - however I always use calculator.startDateTime as start date time of Task SLA should not change - even if this script is running later again.


I am not following....   This afternoon i tried to enter another ticket with a SLA of 3/17/17 and my log shows that my diffDays is 5 excluding the weekends that falls short 1 day.