Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Date Time Picker customization

shill
Mega Sage

From a request we had by the process owners of change, we developed a onLoad client script to set the DateTime picker to default to zeros on the time entry so when the icon is clicked, the time is defaulted to 00:00:00 in the popup.

Here is our current code


function onLoad() {
     setDatePickerTime('start_date');
     setDatePickerTime('end_date');
     setDatePickerTime('requested_by_date');
     setDatePickerTime('work_start');
     setDatePickerTime('work_end');
   
function setDatePickerTime(field){
     //Attach an event listener to set default time value for date picker
     Event.observe(g_form.getControl(field).next('a'), 'click', function() {
           $('GwtDateTimePicker_hh').value = '00';
           $('GwtDateTimePicker_mm').value = '00';
           $('GwtDateTimePicker_ss').value = '00';
     });
}   
}


Works fine in Aspen, but not in Berlin. We are getting java errors in IE and although we do not get errors in Chrome/Firefox, it does not change the time entries to zeros.
Does anyone have any ideas what changes I might make to allow this to work again in Berlin?
17 REPLIES 17


$('GwtDateTimePicker_ampm').value = 'am'


or


$('GwtDateTimePicker_ampm').value = 'pm'


Ruth_Porter
Kilo Explorer

This has been working OK pre Fuji but on fuji I get an error - any ideas?


Hey Ruth,



Did you end up finding a solution for this?



Thanks,


Tony


Community Alums
Not applicable

I've been using the SNGuru solution since Berlin and it has been working great until Fuji.   I just found that I needed to make two simple changes to get it working again. Remove the 'a' from the next() and then set the timeout to 300. Event.observe($(g_form.getControl(field).id).next(), 'click', function() {             setTimeout("$('GwtDateTimePicker_hh').value = '00';$('GwtDateTimePicker_mm').value = '00';$('GwtDateTimePicker_ss').value = '00';",300);     });


Hi Shannon,



It is still not working in Fuji for me.



could you plesae help me with it ?