Narsing1
Mega Sage

The calculation of SLA is dependent on various SLA Definition settings when you configure.  One of them is "Timezone Source".  Here I am taking a scenario that can be an use case where the need of Timezone source is very important.

Scenario#1

A Group consisting of Members from USA & India.  An Incident has been assigned to this group. Ideally the SLA should calculate based on the Assignee's timezone because the resolution needs to be done by the Assignee and some members working in EST hours & some are working in IST hours.  Going with the default Timezone source may not work in this scenario.  You need to create a custom source for it.

find_real_file.png

Here is how you can create a custom timezone source

1. Go to the Dictionary entry of "Timezone source"

2. Add a choice as shown below

find_real_file.png

3. Go to the OOTB Script include called "SLATimezone" (Note:  You can modify this script even though it is OOTB as modification of this script include is allowed as per comments from Servicenow)

find_real_file.png

Now, add the code like this

SLATimezone.source = function(source, /* task_sla */ gr, taskGr) {
	if (!taskGr || taskGr.sys_id.nil())
		taskGr = gr.task.getRefRecord();

	switch(source) {
		// The caller's time zone
		case 'task.caller_id.time_zone':
			return (SLATimezone._getCaller(taskGr)).time_zone;
		// The SLA definition's time zone
		case 'sla.timezone':
			return gr.sla.timezone;
		// The CI's location's time zone
		case 'task.cmdb_ci.location.time_zone':
			return taskGr.cmdb_ci.location.time_zone;
		// The task's location's time zone
		case 'task.location.time_zone':
			return taskGr.location.time_zone;
		// The caller's location's time zone (old and new property values)
		case 'task.caller_id.location.u_time_zone':
		case 'task.caller_id.location.time_zone':
			return (SLATimezone._getCaller(taskGr)).location.time_zone;
		case 'task.assigned_to.time_zone':
			return taskGr.assigned_to.time_zone;
		// (add your own ideas here)
		default:
			return null;
	}
};

4. You are all set to use this source now.

find_real_file.png

 Let me know if any further information is needed.

Thanks,

Narsing

Comments
mcconnellsj
Kilo Sage

Hi - nice work.

We did something similar but simply amended the default returned value to be the custom timezone we required (assignment groups' schedule's timezone).  This meant we always had a timezone rather than ? and this suited the business requirement "if in doubt, the timezone of the team dealing with the task is fine".

Mukhesh Krishn2
Mega Explorer

Hi @Narsing ,

Speaking about Scenario#1, As the SLA should calculate based on Assignee's timezone and some Assignee's are working in EST hours & some are working in IST hours. So we created a custom Timezone source as "Assignee's Time Zone".

My Question here is, What will be the Schedule for the same SLA? Because, if we provide 08:00-06:30 M-F on a floating TimeZone, it mismatches the working hours from different countries, As Assignee from India will work in a different schedule(Eg. 10:00-07:30 M-F) & Assignee from Canada will work in a different schedule(Eg. 08:00-06:30 M-F).

What will be the Schedule source & Schedule for this SLA?

Could you please share your idea here as we are in a need for a similar kind of requirement.

 

Thanks,

Mukhesh

israyalkhan1
Tera Contributor

Hi @Narsing1 ,
I have also configure the same for custom timezone source but it is not working please help me this - 
I have create a new field on task table added to form - "SLA timezone" it is a reference field and have user also

Screenshot 2025-08-12 035409.png

 and also I have created Choice option in TimeZone Source field and selected that on SLA definition
 

israyalkhan1_2-1754951237061.pngisrayalkhan1_3-1754951272332.png

and then I have edited the OOB script include "SLA TimeZone" 

israyalkhan1_4-1754951337094.png

after configure all of this then I check by creating new case, it is not working and SLA taking US/Easten timezone but the field user has Europe/Amsterdam Timezone
please help me with this and let me know is there anything I have done wrong.

Version history
Last update:
‎11-08-2021 06:06 PM
Updated by: