TimeZone in Email Notification is not shown up according to the User's timezone

snowlearner
Kilo Expert

Hello Everyone,

There is a custom field on the incident form capturing the time and date. It shows the correct time according to the logged in user's timezone. But as per the update made on the ticket, an email triggers shows some information including this date and time value as well but the date and time value are not shown up according to the recipient's timezone.

For Eg : User A sees the form with the value of 20-03-2013 16:00:00 and having the time zone of GMT + 8. And User B sees the same form with the value of 20-03-2013 08:00:00 and having the time zone of GMT. So, both of the users see the correct time on the forms. But when they get the same information in the email, they receive the value of 20-03-2013 01:00:00 (this value was entered by some other user at the insertion of this ticket).

Could someone please tell me how the user is not able to receive the date time values in their timezone only as they are seeing on the forms.

thanks...

1 ACCEPTED SOLUTION

neetusingh
Giga Guru

You can give it a try -



<mail_script>


  var grt = new GlideRecord('sys_user');


  grt.addQuery('sys_id',<sys_id of the field(user) to whom the email should be sent>);


  grt.query();



  if(grt.next())


  {


  var timezone = Packages.java.util.TimeZone.getTimeZone(grt.time_zone);


  var gdt = new GlideDateTime(<date_field>); // date field which needs to be shown up according to user's timezones.


  gdt.setTZ(timezone);


  template.print("Date and Start Time:"+gdt.getDisplayValue());


  }


  </mail_script>


View solution in original post

15 REPLIES 15

Kalaiarasan Pus
Giga Sage

as per my knowledge email uses the system timezone instead of user time zone .. you could convert the time as per user's timezone before sending the mail and send it


Thanks Kalai. But that's what I want to know, how should i change it in the email notification before sending it to the users


this is one of the old codes...



https://community.servicenow.com/message/716793#716793



you might need to change the packages in the script as per new convention ....


thanks kalai. I tried with the script, but somewhere something is preventing its working.


Currently, I am using the Eureka release. So Could you tell me please where in the script, I have to modify the package call..