How to auto set user timezone based on location value?

Chin4
Tera Expert

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.

6 REPLIES 6

Community Alums
Not applicable

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

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

Chin4
Tera Expert

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