- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2020 11:16 PM
Hello,
We have 2 fields in a form.
1. Expected Start Date/Time
2. Expected End Date/Time
The above 2 fields show the system date/time.
I want 2 more fields below below the above mentioned fields with name :
1. Expected Start Date/Time (EST)
2. Expected End Date/Time (EST)
Requirement :
Expected Start Date/Time (EST) will be copied from Expected Start Date/Time once the user fill this field and show EST time.
Expected End Date/Time (EST) will be copied from Expected End Date/Time once the user fill this field and show EST time.
Can someone please help in how to achieve this functionality?
NOTE : The fields are in scoped application.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2021 11:57 PM
Okay.
Hi create a SI in global scope and then call that Si from your client script. Then you can use the following code to convert your date/time to EST format.
Script Include
getConvertedDate: function() {
var mydate = new GlideDateTime(this.getParameter('sysparm_date').toString());
var gdt1 = new GlideDateTime();
//sets to EST
var tz = Packages.java.util.TimeZone.getTimeZone("EST");
gdt1.setTZ(tz);
gdt1.setValue(mydate);
return gdt1.getDisplayValue(); //returns the date/time in EST timezone as a string.
},
Mark the comment as a correct answer and also helpful if this helps to solve the problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2021 04:36 AM
Hi Asif,
I already tried this. It is not working as my mail_script and notification is in scoped application.
It is not printing anything.
mal_script : in scoped application.
Can we make mail_script in global and call from notification which is in scoped application if that way it works?
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2021 04:41 AM
In that case, lets call the same SI which we have used earlier. You can modify that SI function slightly like this so that it can be used from server side as well as client side.
getConvertedDate: function(mydate) {
var mydate = JSUtil.nil(mydate) ? new GlideDateTime(this.getParameter('sysparm_date').toString()) : mydate;
var gdt1 = new GlideDateTime();
//sets to EST
var tz = Packages.java.util.TimeZone.getTimeZone("EST");
gdt1.setTZ(tz);
gdt1.setValue(mydate);
return gdt1.getDisplayValue(); //returns the date/time in EST timezone as a string.
},
Then in your mail script, simply call
template.print(new global.your_si_name().getConvertedDate(current.your_field_name));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2021 04:48 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2021 05:14 AM
Hi,
Try the code that I gave above. and pass your Expected start/end date field (not est) to the SI and it will give you back the EST field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2021 08:22 AM
Hi Asif,
It is working now. Thanks for your help. Really appreciate.
Thanks.