- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2016 09:54 AM
Hi,
I am trying to send the SLA Time to Resolve value in an email when an incident is opened.
I am using the following email script:
checkETA();
function checkETA() {
var encQuery = 'slaSTARTSWITHTTR^stage=in_progress';
var eta = new GlideRecord('task_sla');
eta.addQuery('task', current.sys_id);
eta.addEncodedQuery(encQuery);
eta.query();
while(eta.next()) {
template.print('Estimated time of resolution: ' + eta.planned_end_time.getDisplayValue());
}
}
However, what I am getting in the emails, regardless of the time zone of the customer who opened the incident, is:
Estimated time of resolution: 2016-10-21 23:55:31 IDT --> Israel Daylight Time
I thought eta.planned_end_time.getDisplayValue() should show the user's timezone
Any Idea why the correct information is not displayed?
Harel
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2016 05:13 PM
Hi Harel - I get it. Would you please run this and see what you get? I think this will give us a clue:
// print eta.planned_end_time
template.print(eta.planned_end_time);
template.print(eta.planned_end_time.getDisplayValue());
// print GlideDateTime(eta.planned_end_time)
var gdt = new GlideDateTime(eta.planned_end_time);
template.print('GlideDateTime(eta.planned_end_time)');
template.print(gdt);
template.print(gdt.getDisplayValue());
// set user timezone
var timezone = Packages.java.util.TimeZone.getTimeZone(current.caller_id.time_zone);
gdt.setTZ(timezone);
template.print('set user timezone');
template.print(gdt);
template.print(gdt.getDisplayValue());
// print GlideDateTime(eta.planned_end_time.getDislayValue())
var gdt = new GlideDateTime(eta.planned_end_time.getDislayValue());
template.print('GlideDateTime(eta.planned_end_time).getDislayValue()');
template.print(gdt);
template.print(gdt.getDisplayValue());

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2016 05:13 PM
Try this
var gdt = new GlideDateTime(eta.planned_end_time.getDislayValue());
template.print(gdt.getValue());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2016 05:13 PM
Hi Harel - I get it. Would you please run this and see what you get? I think this will give us a clue:
// print eta.planned_end_time
template.print(eta.planned_end_time);
template.print(eta.planned_end_time.getDisplayValue());
// print GlideDateTime(eta.planned_end_time)
var gdt = new GlideDateTime(eta.planned_end_time);
template.print('GlideDateTime(eta.planned_end_time)');
template.print(gdt);
template.print(gdt.getDisplayValue());
// set user timezone
var timezone = Packages.java.util.TimeZone.getTimeZone(current.caller_id.time_zone);
gdt.setTZ(timezone);
template.print('set user timezone');
template.print(gdt);
template.print(gdt.getDisplayValue());
// print GlideDateTime(eta.planned_end_time.getDislayValue())
var gdt = new GlideDateTime(eta.planned_end_time.getDislayValue());
template.print('GlideDateTime(eta.planned_end_time).getDislayValue()');
template.print(gdt);
template.print(gdt.getDisplayValue());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2016 04:29 AM
Hi John,
The //set user timezone part is what I needed. The code looks like this:
checkETA();
function checkETA() {
var encQuery = 'slaSTARTSWITHTTR^stage=in_progress';
var eta = new GlideRecord('task_sla');
eta.addQuery('task', current.sys_id);
eta.addEncodedQuery(encQuery);
eta.query();
while(eta.next()) {
var gdt = new GlideDateTime(eta.planned_end_time);
var timezone = Packages.java.util.TimeZone.getTimeZone(current.caller_id.time_zone);
gdt.setTZ(timezone);
template.print(gdt.getDisplayValue() + '<br \>');
}
}
An observation:
Opening an incident for someone else, in another time zone, or even impersonating that person, will still show in the task_sla the time according to impersonator's time zone. The email, however, will show the correct time and time zone with the above code.
Thanks for the patience and help with the troubleshooting and thought-process.
Harel

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2016 06:19 PM
FYI: Package calls will get flagged on ACE inspections if anyone ever chooses to do that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2016 09:12 AM
Hi Abhinay,
Can you explain or refer me to a link about this?
What is the alternative?
Thanks,
Harel