Multiple Timezones on SLA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2017 04:28 PM
Is it possible to start a SLA on one timezone and end on another timezone (dynamic)
E.g. I want the SLA to start on Caller Timezone but Stop on a Location Timezone thats not on incident and that location can also be dynamic.
If lets say the SLA starts at 9 AM on Monday, it should be breached on the End of next Business day of some other Location timezone thats calculated dynamically.
Is that feasible?
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2017 06:37 PM
Hi Poonam,
You can create a custom relative duration.
For example, I can set duration of an SLA by reading a field on the parent table.
Relative Duration module: create new record & set end date dynamically:
var dueDuration = current.end_date.getGlideObject();
calculator.endDateTime = dueDuration;
In your SLA config, select this duration.
=========
Similar to this, you can calculate the time for a specific timezone and calculate the duration.
End your SLA on that duration.
Regards
Vab Singhal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2017 09:12 PM
Hi Poonam,
Prior to Helsinki, where the schedule and timezone sources were set for all the SLA Definitions by properties, this was more difficult to customize. Since Helsinki, you have the option of specifying both the schedule source and the timezone source per SLA Definition. In other words, as values in the SLA Definition record itself. And you can put the reference value for the schedule and the string value for the timezone into fields in the task record, or pretty much anywhere else, and make the SLA Engine use those values in your SLA Calculations.
Per Vab's response, you want to use a Relative Duration. Relative durations allow you to write your own script to calculate the planned_end_time for your task_sla.
We provide as an example the Relative Duration script 'End of next business day', which is very close to what you are requesting.
Here is the script:
// Next business day by 5pm
var days = 1;
calculator.calcRelativeDueDate(calculator.startDateTime, days, "17:00:00");
Here is how this script works with your SLA Definition and the SLA Engine:
- When the SLA Definition is processed and a new task_sla record is created from it, the schedule reference and the timezone value specified in the SLA Definition get copied into the task_sla record. At this time, the start time of the SLA and either the fixed duration value or the reference to the relative duration script reference is also populated.
- The SLA Engine uses the _newDurationCalculator() function in the SLACalculatorNG script include to calculate the planned_end_time value.
- The function initializes a new DurationCalculator object.
- It takes the schedule and timezone from the task_sla record and applies them to the DurationCalculator object with its setSchedule() method.
- Note that there is code in place to make sure these are a valid schedule and timezone, otherwise it reverts to the system settings.
- It takes the start time from the task_sla record and applies it to the DurationCalculator object with its setStartDateTime() method.
- If the task_sla has a fixed duration, the DurationCalculator object uses it with its calcDuration() method.
- If the task_sla refers to a relative duration script, the DurationCalculator object uses it with its calcRelativeDuration() method.
- Note that the DurationCalculator is expected to determine an end date time for the object.
- The typical last expression of the relative duration script, like shown above, uses the calcRelativeDueDate() method of the DurationCalculator object.
- The _newDurationCalculator() function returns the calculated DurationCalculator object to the calling function _createTaskSLA().
- The _createTaskSLA() function uses the DurationCalculator getEndDateTime() to retrieve the value from the calculated object and set it in the planned_end_time.
I do want to caution you that the start time is going to be adjusted to system time based on the timezone of the thread/session where it is running. If this is different from the timezone specified for the DurationCalculator object, you might get an unexpected result. An example of this would be if the relative duration script is being executed in a worker thread so it is on system time (for example, US/Pacific) but the timezone in the SLA Definition was specified as IST. To get this to calculate correctly, you will need to set the timezone of your thread to the timezone in your DurationCalculator, do you calculations, and then set it back to the system time when you are done.
Sample code for changing your timezone and setting it back:
var tz = <string for whatever you want your timezone to be, like Europe/London>;
var originalZoneName = gs.getSession().getTimeZoneName();
gs.getSession().setTimeZoneName(tz);
<code to do calculations>
gs.getSession().setTimeZoneName(originalZoneName);
Ed Wajs
Technical Support Developer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2017 09:25 AM
Poonam,
We are glad you took advantage of the ServiceNow Community to learn more and to get your questions answered. The Customer Experience Team is working hard to ensure that the Community experience is most optimal for our customers.
If you feel that your question was answered, we would greatly appreciate if you could mark the appropriate thread as "Correct Answer". This allows other customers to learn from your thread and improves the ServiceNow Community experience.
If you are viewing this from the Community inbox you will not see the correct answer button. If so, please review How to Mark Answers Correct From Inbox View.
Thanks,
Shivani Patel