Email Notification cannot get the User Time Zone

Mohamed Faizel
Giga Expert

Hi,

When we receive the email notifications from service now including work notes in the body, it has shown the instance time zone and time and it does not fetch the users time zone with latest updated time in email.

Can any one please help on this?

22 REPLIES 22

Something i found from Wiki. Please look into this it can help how to convert time zones



  1. 1. //converting GMT to Canada/Eastern  
    1. 2.  
  2. 3. var tz = Packages.java.util.TimeZone.getTimeZone("Canada/Eastern");  
    1. 4. gDate.setTZ(tz);  


...right after you initialize the variable and before you assign the date to it.     You should end up with:



  1. 1. var gDate = Packages.com.glide.glideobject.GlideDateTime();  
    1. 2. //converting GMT to Canada/Eastern  
  2. 3.  
    1. 4. var tz = Packages.java.util.TimeZone.getTimeZone("Canada/Eastern");  
  3. 5. gDate.setTZ(tz);  
    1. 6. gDate.setValue(msDate);  

I think this type of Packages Call is no longer supported in the more recent versions of ServiceNow (I think Calgary and beyond).   Can someone confirm this?



I will still try to give this a shot.


With the packages call, past Calgary you can look up a new GlideScriptable class to do the same thing:



http://wiki.servicenow.com/index.php?title=Packages_Call_Replacement_Script_Objects


Hi Darryl,



Does it matter where in the email notification that I can put your code in...



<mail_script>


    var user = gs.getUser();


    var timeZone = String(user.getTZ()); // <---- You can change this line to get the user you wish to use the time zone for or you can use a hard coded time zone.e.g: 'US/Eastern'


    TimeUtils.changeTimeZone(current, 'work_start', timeZone);


    template.print('First Task Start Date: ' + current.work_start.getDisplayValue());


</mail_script>


Hi Giovanni,



Depending on which version you are running it can either go anywhere in the email body html or in the new mail script associated records with a reference in the email body html.