User Time Zone is not getting mapped based on Location

SNOW46
Tera Contributor

Hello Team,

I have configured a record producer for creating a new Incident where I have added the Location and Time Zone fields on the form. As per the current configurations, I have mapped the Time Zone for each location in the location table. But when the form loads the Location is also not populating as per the current user's location as well as the Time Zone field is not getting properly mapped.

Can someone help me out on this how to fix this as I need to give a demo on this?

 

Thanks

14 REPLIES 14

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi SNOW,

Timezone in location table (cmn_location) and user table (sys_user) aren't synced. To use the timezone in the user's table, it's necessary to populate time_zone field in the sys_user table. If the time_zone in sys_user is empty, system default time zone is used. By default, user's time_zone field is empty so the system timezone is used. 

Hitoshi Ozawa
Giga Sage
Giga Sage

Following script may be used to fill timezone and location fields.

  1. Create Script Include (Client callable is checked)
    var UserInfoClient = Class.create();
    UserInfoClient.prototype = Object.extendsObject(AbstractAjaxProcessor, {
        getUserLocation: function() {
            var gr = new GlideRecord('sys_user');
            if (gr.get(gs.getUserID())) {
                return gr.location.name;
            }
        },
        getUserTimezone: function() {
            var gr = new GlideRecord('sys_user');
            if (gr.get(gs.getUserID()) && gr.time_zone.length > 0) {
                return gr.time_zone;
            }
            return gs.getProperty("glide.sys.default.tz").toString();
        },
        type: 'UserInfoClient'
    });​
  2. Create field "Location" on Record Producer form of type Single Line Text
    Set default value to following:
    javascript: new UserInfoClient().getUserLocation();​
  3. Create field "Timezone" of Record Producer form of type Single Line Text
    Set default value to following:
    javascript: new UserInfoClient().getUserTimezone();​

Execution:

find_real_file.png

Hi Hitoshi,

I have implemented the script and the functionality as suggested by you.And even I have mapped the Location and Time Zone as well in sys_user record. But still it is taking the default Time Zone the one which I have already de-activated it.

Can you please suggest here.

 

Thanks

Hi Hitoshi,

I need your help here.The script has failed working here.When I clear the Caller, and put a new Caller Name, the location is not getting populated anymore?

Please help me out here.

 

Thanks