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
‎10-16-2015 11:02 AM
Daryll,
I realize that the time zone in email notifications follows the system time zone. However, is there a way within the email notification or email template to display a field in a different time zone? For example, I have two separate time fields in my email notification that contain Pacific Time zone and an Eastern Time zone. The eastern time zone is automatically converted to pacific time zone. I would like the eastern time zone field to reflect eastern not pacific time zone.
Current:
CA Lab Finished Time: 21:00:00 PST
NJ Lab Finished Time: 01:00:00 PST
Proposed:
CA Lab Finished Time: 21:00:00 PST
NJ Lab Finished Time: 04:00:00 EST
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2017 11:49 AM
You can use below email script and script include to show the time in User timezone(assigned to/contact).
1) Email Script:- I am getting last 5 journal entries to print in the email body.
var max_to_process = 5;
var processed = 0;
var ut = current.contact.time_zone;
//If there is not timezone then set it to US/pacific as per system time zone.
if(!ut)
ut = "US/Pacific";
var journalEntry = new GlideRecord('sys_journal_field');
journalEntry.addQuery('element', 'comments');
journalEntry.addQuery('element_id',current.sys_id);
journalEntry.orderByDesc('sys_created_on');
journalEntry.query();
while(journalEntry.next() && (processed < max_to_process)) {
var dt = journalEntry.sys_created_on;
var str = journalEntry.value;
var str1 = str.replace(/\[code]/g, '');
var str2 = str1.replace(/\[\/code]/g, '');
var user1 = journalEntry.sys_created_by;
var gr = new GlideRecord('sys_user');
gr.addQuery("email",user1);
gr.query();
if(gr.next()){
user1 = gr.name;
}
var dt1 = new getUsersTime().getUserTime(dt,ut);
template.print('<div><p><font size="2" face="helvetica"><strong>');
template.print('<hr>');
template.print(dt1+" -"+user1);
template.print('</strong></font></p></div>');
template.print('<p><font size="2" face="helvetica">' + str2 + '</font></p>');
processed ++;
}
})(current, template, email, email_action, event);
Script Include:-
var getUsersTime = Class.create();
getUsersTime.prototype = {
initialize: function() {
},
getUserTime: function(date,usertimezone){
var timezone = Packages.java.util.TimeZone.getTimeZone(usertimezone);
var gdt = new GlideDateTime(date);
gdt.setTZ(timezone);
var set1 = gdt.getTZOffset();
gdt.setNumericValue(gdt.getNumericValue() + set1);
return gdt;
},
type: 'getUsersTime'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2015 11:33 AM
Hi,
I have a situation where in Change Management Notifications the Planned Start Date and time and Planned End Date and time always show as the System (Europe/London) timezone.
Could I use this script in the approval e-mail notifications to change the Planned Start Date and Time and Planned End Date and time to display in the user's timezone?
And since I am new to ServiceNow where would you create the TimeUtils.changeTimeZone function.
Thanks
Max
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2014 02:34 PM
Has anyone tried Daryll's solution? It is working great for me in Dev, but I'd like to hear someone with SN to give an opinion on it's safety.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2014 02:30 AM
Just to give you some confidence in my script and it's current usage. It has been used by 2000+ users of SNow across Europe for the last 6 months and works perfectly in various calls from other scripts. As with any new script you're best to test this in a dev environment first if only to get used to the usage of it before going live.
If you need any further help with this let me know.