Time zone e-mail script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2022 05:29 AM
Hello everyone
I currently have the following script to change the date format in my email:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Add your code here
var date = new GlideDateTime(current.parent_incident.sys_created_on);
template.print(date);
})(current, template, email, email_action, event);
But he is using the GMT time zone. I need to use America/Sao_Paulo.
Can you help me?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2022 05:48 AM
Check this :
https://community.servicenow.com/community?id=community_question&sys_id=2adfc3a5dbdcdbc01dcaf3231f9619f2
https://community.servicenow.com/community?id=community_question&sys_id=789e7665db58dbc01dcaf3231f961960
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2022 05:54 AM
Hello,
-----------------------------------------------------------------------------------------
The setValue() and getValue() methods require parameters in the UTC time zone and internal format. Other formats may return invalid results.
The toString() method returns the same string as the getValue() method.
The setDisplayValue() and getDisplayValue() methods require parameters in the local time zone (user/system) and local format (user/system). Other formats may return invalid results.
//Example: If user’s date time format is MM.dd.yyyy HH:mm:ss
// Do this
var input = “08.05.2015 16:21:47”;
var gdt = new GlideDateTime();
gdt.setDisplayValue(input);
// Not this
var input = “08.05.2015 16:21:47”;
var gdt = new GlideDateTime(input);
-----------------------------------------------------------------------------------------
So in your case try to use
var gdt = new GlideDateTime();
gdt.setDisplayValue(current.parent_incident.sys_created_on);
template.print(gdt);
Regards,
Akshay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2022 02:03 AM
Hi Matheus Rissi,
Didn't hear back on this.
Is your issue resolved? If yes, feel free to mark helpful/correct, so it will be helpful for others looking for similar query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2022 02:42 AM
Hi,
are you saying irrespective of whatever timezone the recipient is the date/time value should always show value in America/Sao_Paulo timezone?
Can you share your exact requirement?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader