- 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:54 AM
Have you tried the the function <date time>.getUserTimeZone().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2014 01:25 AM
- 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 05:24 AM
Thanks Neetu!
This has made my requirement worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2023 03:07 AM
what if want this for the case table : have tried this but not working.
var userId = gs.getUserID();
var grt = new GlideRecord('customer_contact');
grt.addQuery('sys_id', userId);
grt.query();
if (grt.next()) {
var timezone = Packages.java.util.TimeZone.getTimeZone(grt.time_zone);
var gdt = new GlideDateTime();
gdt.setTZ(timezone);
template.print("Date and Start Time: " + gdt.getDisplayValue());
}