Need to convert Date field to populate only in EST
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2022 04:27 AM
Hi
I need to make a date/time field to populate only in EST and not change according to the user time zone who selects them. I have written a client script and script include to achieve this but I am getting by default, 2022-06-01 and time 7.30 hours ahead of the time selected. Can someone please guide mw with the correct query,
Below is the query that I used,
Catalog Client Script :
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('getDateInEST');
ga.addParam('sysparm_name', 'getConvertedDate');
ga.addParam('sysparm_date', g_form.getValue('statement_date')); //Getting the Date field here
ga.getXML(getDataResponse);
function getDataResponse(response) {
var favorites = response.responseXML.getElementsByTagName("favorite");
g_form.setValue('account_number_or_feed_id', favorites[0].getAttribute('statement_date'));
}
}
Script Include :
var getDateInEST = Class.create();
getDateInEST.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getConvertedDate: function() {
var mydate = new GlideDateTime(this.getParameter('sysparm_date').toString());
//sets to EST
var tz = Packages.java.util.TimeZone.getTimeZone('US/Eastern');
var gdt = new GlideDateTime();
gdt.setTZ(tz);
var abc = gdt.getDisplayValue();
var favs = this.newItem('favorite');
favs.setAttribute('statement_date',abc);
},
type: 'getDateInEST'
});
- Labels:
-
Request Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2022 03:52 AM
Hi Ankur,
This is returning 'Null' as the value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2022 04:58 AM
Hi,
so what debugging did you perform?
is gs.info() returning valid values in script include?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2024 06:04 AM
Hi @Ankur Bawiskar ,
in script include for source time zone it is only used GMT, but I need to handle all time zones, can you please help me on this.
Thanks & regards,
Hemanth,