- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2014 01:07 AM
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...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2014 05:14 AM
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>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2014 01:46 AM
just copy paste and check ... shouldn't give any errors per me ....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2014 02:03 AM
I am getting an error - org.mozilla.javascript.EcmaError: "TimeUtils" is not defined

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2014 02:04 AM
give the script include name as 'TimeUtils' and copy paste
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2014 02:14 AM
Have you created a TimeUtils script include? 'TimeUtils script include script inclide is not available ootb.
But you can alos use the below script.
var utz = gs.getUser().getTZ().toString();
var tz = Packages.java.util.TimeZone.getTimeZone(utz);
var gdt = new GlideDateTime(); //your date time field
gdt.setTZ(tz);
gs.print(gdt);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2014 02:21 AM
I just checked the script includes again, in the OOTB there is a script include 'TimezoneAjax' whcih contains chnageTimeZone function.
So with the Kalai's solution replace 'TimeUtils' with 'TimezoneAjax'.
So your code should be something like TimezoneAjax.changeTimeZone(<time zone value>);