- 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
09-19-2017 11:48 AM
The ServiceNow Wiki content is no longer supported. Updated information about this topic is located here: GlideDateTime
Visit http://docs.servicenow.com for the latest product documentation

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2016 09:17 AM
To be honest, I don't think of any alternative. Even I was using these packages calls before, when chuck told me about this ACE inspection.I am adding chuck and I hope he can find an alternative.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2016 05:06 PM
Packages calls are a way to circumvent the published JavaScript API. Most are unpublished (and all are undocumented). They allow one a way to "reach" down to the methods and properties of the Java code layer.
They offered great functionality, but also "handcuffed" you to the specific class, method, and property. If ServiceNow developers decided to change the way that particular class/method behaved, your JavaScript broke. Instead they came out with a published list of the most common Packages as GlideScriptable objects. This is the safe and supported way to access the methods/functions on the platform.
http://wiki.servicenow.com/index.php?title=Packages_Call_Replacement_Script_Objects#gsc.tab=0
As for ACE (automated configuration executive), it is an app on HI available to SN employees to check a system's configuration against a set of known best practices. If any bad practices are found (like synchronous AJAX, Package calls, and more). This is normally run before sprint completion and release dates to ensure compliance with best practices.
http://wiki.servicenow.com/index.php?title=Technical_Best_Practices#gsc.tab=0

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2016 05:35 PM
Thanks chuck for the detailed explanation. It is very helpful. Just curious, if you were able to find any Glide api to get the timezone and set the timezone as mentioned in this question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2016 06:27 PM
Have you taken a look at the GlideDateTime() setTZ() method?