SLA Duration based on Creation time of day?

mw1307
Giga Contributor

Hi,

I need to set up some SLA(s) where the clock runs 24x7, but the SLA threshold varies according to the time of day.

i.e.

A. Logged/Created During working hours,   SLA is 30 mins - and the clock runs 24x7

(otherwise I understand the clock would pause when we go out of hours for a ticket logged very close to the end of working hours)

B. Logged/Created Outside working hours, the SLA is 2 hours - and the clock runs 24x7.

How might I do this?

I've been fishing about with Relative times - and I THINK I could go from 'zero to breached' in an instant by setting the StartTimer to have a retrospective start and monitor the Created Time as being At of before 2 hours ago. -but... that doesn't allow for workflow processes to send reminders at 50% of the time etc.

Any suggestions?

cheers

Martin

p.s. I'm a novice, so please excuse any newbie mistakes.

1 ACCEPTED SOLUTION

Aditya Mallik
ServiceNow Employee
ServiceNow Employee

Hi,



You can easily achieve this by using a relative duration.



Sample script for the relative duration would look like:



var inSchedule = new GlideSchedule("08fcd0830a0a0b2600079f56b1adb9ae").isInSchedule(new GlideDateTime());


if (inSchedule) {


calculator.calcDuration(30*60);


}


else {


calculator.calcDuration(2*60*60);


}



The logic is pretty simple:


1. Have a pre-defined schedule that gives you the working hours and non-working hours. Get the SysId of that Schedule. In this example I have used the OOB 8-5 weekdays.


2. Use the GlideSchedule API to initialize the schedule and understand if the current time is in Schedule (within working hours) or not.


3. If within schedule (working hours), set the due date to be 30 minutes from now. If not within the schedule, set the due date to be 2 hours away.



Note: We need to use the calculator object that is available OOB in the Relative Duration script include. Use the calcDuration API to add the number of seconds relative to current time.



You can then use this relative duration in the SLA Definition. Ensure to set the "Schedule source" in SLA Definition to "No Schedule", else as you mentioned earlier, the Task SLA will pause once it gets into out of business hours.



I am attaching the sample XML files for the Relative Duration and SLA Definition. You can tweak these to suite your business needs. Instead of hard coding the schedule, you can derive the value at run time from the Task table or any of the fields on the Task that have a schedule specified on them. Ex: Caller, etc.



I have tested this in my local instance, and it works fine. Let me know if you face any issues.



Thanks.


View solution in original post

11 REPLIES 11

Aditya Mallik
ServiceNow Employee
ServiceNow Employee

Hi,



You can easily achieve this by using a relative duration.



Sample script for the relative duration would look like:



var inSchedule = new GlideSchedule("08fcd0830a0a0b2600079f56b1adb9ae").isInSchedule(new GlideDateTime());


if (inSchedule) {


calculator.calcDuration(30*60);


}


else {


calculator.calcDuration(2*60*60);


}



The logic is pretty simple:


1. Have a pre-defined schedule that gives you the working hours and non-working hours. Get the SysId of that Schedule. In this example I have used the OOB 8-5 weekdays.


2. Use the GlideSchedule API to initialize the schedule and understand if the current time is in Schedule (within working hours) or not.


3. If within schedule (working hours), set the due date to be 30 minutes from now. If not within the schedule, set the due date to be 2 hours away.



Note: We need to use the calculator object that is available OOB in the Relative Duration script include. Use the calcDuration API to add the number of seconds relative to current time.



You can then use this relative duration in the SLA Definition. Ensure to set the "Schedule source" in SLA Definition to "No Schedule", else as you mentioned earlier, the Task SLA will pause once it gets into out of business hours.



I am attaching the sample XML files for the Relative Duration and SLA Definition. You can tweak these to suite your business needs. Instead of hard coding the schedule, you can derive the value at run time from the Task table or any of the fields on the Task that have a schedule specified on them. Ex: Caller, etc.



I have tested this in my local instance, and it works fine. Let me know if you face any issues.



Thanks.


Hi Aditya,


Thanks for this, very helpful.


I note that Relative Durations are not compatible with Pause criteria for SLA's - I'm going to have to think about that one.



cheers


Martin


Aditya Mallik
ServiceNow Employee
ServiceNow Employee

Thanks Martin. Can you elaborate on what you meant by "Relative Durations are not compatible with Pause criteria for SLA's".


Maybe I can help you with that.


Hi Aditya


it's on this page   http://wiki.servicenow.com/index.php?title=Defining_Relative_Durations#gsc.tab=0


below is a quick screen snip.   It would be great if there is a workaround.   It is frustrating as it stands.   I'm guessing there is some strange interaction possibility with start conditions and pause logic, but I can't see the problem(as a novice).



find_real_file.png