Set user time zone to default to location time zone

shill
Mega Sage

I would like to be able to set the time zone for a location and for users that have that location in their user record, to have the location time zone as their default time zone. As our proposed feed of user data does not indicate time zone preferences, just looking for an easier way to default the time zone on the initial and subsequent loads of user data.

For example.
Joe Smith's user data is imported to the user record with a location of Dallas, TX. The system then sets Joe Smith's time zone in his user record to what is indicated as the time zone on the location record for Dallas.

I would think this would be possible with some scripting in the user time zone field default value, or am I way off?

1 ACCEPTED SOLUTION

jacob_kimball
ServiceNow Employee
ServiceNow Employee

Generally, that should work. My suggest would be a business rule run on update of the user record with a condition for when the user location changes. The rule would be something like:



current.time_zone = current.location.time_zone


View solution in original post

10 REPLIES 10

Hmm, I did wonder about that but I noticed when testing if I set a user's time zone manually and then later update the relevant Location.Time zone and then run the script, the updated time on the manually updated user remains as it is (and does not show the Updated time of those that were updated by the script) which indicates to me the script hasn't written to the user record with the Location.Time zone value already there, but I could be wrong about that?

Is it feasible/would it make sense to add to the initial query in the script with something like:

gr.addQuery('time_zone','')

and if so would it be a separate line to the active query already there (below)?

gr.addQuery('active',true); 

Thank-you.