Email Notification cannot get the User Time Zone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2014 05:30 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2014 02:46 PM
There is a flag in the system properties to show time zones on dates in notifications.
This however, only seems to work in date times that you can get to easily from the record.
In approvals though, I have the problem that I can't get to the record easily, because an approval only has a sys_id point to a table but the table name is stored on the approval, so I have to make a GlideRecord call, and then programmatically make a string out of a date time and 'print' it into the notification. This 'printing' doesn't include the time zone.
Anyway, for you maybe it is email to set the system property. Search on *timezone in sys_properties.list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2014 02:10 AM
Hi robbika,
Thanks for the reply, I have tried in sys_properties.list and also tried glide.email.smtp.timezone and the value is sys_user.timezone. That also not working. Do you any idea on this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2014 06:28 AM
TimeUtils.changeTimeZone = function (object, prop, timeZone) {
if (typeof object != "object") {
//Custom logger used ... You can change this to gs.log
Logger.error('Invalid object passed in to TimeUtils.changeTimeZone(): ' + typeof object, 'TimeUtils');
return false;
}
try {
if (!JSUtil.nil(prop) && !JSUtil.nil(timeZone)) {
var tz = Packages.java.util.TimeZone.getTimeZone(timeZone);
object[prop].getGlideObject().setTZ(tz);
}
} catch (ex) {
//Custom logger used ... You can change this to gs.log
Logger.error("Exception at TimeUtils.changeTimeZone: " + ex, 'TimeUtils');
return false;
}
return true;
};
You can use this by making a script include called TimeUtils with the above script in then you can call it in your email notifications like this...
<mail_script>
var user = gs.getUser();
var timeZone = String(user.getTZ());
TimeUtils.changeTimeZone(current, 'work_start', timeZone);
template.print('First Task Start Date: ' + current.work_start.getDisplayValue());
</mail_script>
Where "work_start" is the date you wish to change the time zone for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2015 09:32 AM
Hi Daryll.
Thanks a lot for posting this but please can you advise how in the sample incident notification below I would use the mail script to show the user's timezone for where 'Created:' is stated?
Many thanks,
Daniel
<font face="Calibri">
Short Description: ${short_description}
Click here to view Incident: ${URI_REF}
<hr/>
<b>${priority}</b> | Created: ${sys_created_on}
Categorization: ${category} | ${u_product} | ${subcategory}
<b>${caller_id.name}</b> | ${caller_id.user_name}
${caller_id.title}
Location: <b>${caller_id.location.city}</b> | Desk Location: <b>${caller_id.u_room_number}</b> | Phone: <b>${caller_id.phone}</b>
Machine Name: <b>${u_default_ci}</b>
Opened By: <b>${opened_by}</b> | ${opened_by.phone}
Description: ${description}
</font>