How to auto set user timezone based on location value?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2023 02:54 AM - edited 02-27-2023 02:56 AM
We sync user account from AD to ServiceNow but it does contain timezone data. We do have value for field Location that has timezone set. Is there a way to auto set user timezone based on the Location set for the user?
Thanks in advance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2023 05:50 AM
Hi @Chin4 ,
You can use the Solution mentioned in this thread : https://www.servicenow.com/community/developer-forum/how-to-auto-populate-time-zone-according-to-loc...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2023 12:37 AM
Hi Sandeep,
Good day and I hope you are well.
I am still trying to understand how to set transform map configuring field mapping map that time zone field of user.location.u_site.u_time_zone to sys_user timezone field.
Using solution in BR with current.time_zone = current.location.u_site.u_time_zone; does not fully worked.
PS. I am not familiar with Transform Map but understand BR.
Thanks for following up.
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2023 07:50 PM
Hi Sandeep,
I got it working with the script below.
var tz = current.time_zone.toString();
var grUser = new GlideRecord('sys_user');
grUser.addEncodedQuery('location=' + current.sys_id);
grUser.query();
while(grUser.next()) {
grUser.setValue('time_zone',tz);
grUser.update();
}
Regards,
Chin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2023 12:40 AM
Hi Sandeep,
Good day and I hope you are well.
I am still trying to understand how transform map and field mapping map that time zone field of user.location.u_site.u_time_zone to sys_user timezone field.
I use the solution BR with urrent.time_zone = current.location.u_site.u_time_zone but it does not work.
PS. I am not familiar with transform map but understand BR.
Cheers