Comments on: Set Default Date/Time Picker Dialog Time https://servicenowguru.com/client-scripts-scripting/set-default-datetime-picker-dialog-time/ ServiceNow Consulting Scripting Administration Development Tue, 28 May 2024 20:26:22 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Jacques P. https://servicenowguru.com/client-scripts-scripting/set-default-datetime-picker-dialog-time/#comment-8776 Fri, 15 Apr 2016 13:53:36 +0000 https://servicenowguru.wpengine.com/?p=3857#comment-8776 In reply to Cynthia.

Hi Cynthia,

We are on Geneva and I just tried the solution given by Ahmed Hmeid on 23-07-2015, 06:12 (3 posts above yours).

It works perfectly!

]]>
By: Cynthia https://servicenowguru.com/client-scripts-scripting/set-default-datetime-picker-dialog-time/#comment-8775 Thu, 10 Mar 2016 15:24:37 +0000 https://servicenowguru.wpengine.com/?p=3857#comment-8775 We are skipping Fuji and going directly from Eureka to Geneva and just discovered it is not working there either. Anybody have any luck on an alternative yet?

]]>
By: Tina https://servicenowguru.com/client-scripts-scripting/set-default-datetime-picker-dialog-time/#comment-8774 Fri, 26 Feb 2016 14:19:09 +0000 https://servicenowguru.wpengine.com/?p=3857#comment-8774 I have tried multiple versions of this script with no success. Has anyone been able to get this script working in Fuji or have another alternative to defaulting the time of the dateTimePicker?

]]>
By: Ahmed Hmeid https://servicenowguru.com/client-scripts-scripting/set-default-datetime-picker-dialog-time/#comment-8773 Thu, 23 Jul 2015 12:12:08 +0000 https://servicenowguru.wpengine.com/?p=3857#comment-8773 In reply to Mark Stanger.

Had a look into this and looks like the UI renders fractionally slower in Fuji than in Eureka, so the timeout 0 was failing. Also, the DOM has changed so it could not find the element. So changed the setting function to try repeatedly until it finds the element, and also updated the DOM selector to find the element. Seems to do the trick:

setDatePickerTime(‘dateField’);

function setDatePickerTime(field){
//Attach an event listener to set default time value for date picker
Event.observe($(g_form.getControl(field).id).next().down(), ‘click’, function() {
setTimeout(setDefaultTime,0);
});
}
function setDefaultTime() {

if (!$(‘GwtDateTimePicker_hh’)) {
setTimeout(setDefaultTime,0);

}
else {
$(‘GwtDateTimePicker_hh’).value = ’01’;
$(‘GwtDateTimePicker_mm’).value = ’02’;
$(‘GwtDateTimePicker_ss’).value = ’03’;
}

}
}

]]>
By: steve H https://servicenowguru.com/client-scripts-scripting/set-default-datetime-picker-dialog-time/#comment-8772 Thu, 09 Jul 2015 20:39:29 +0000 https://servicenowguru.wpengine.com/?p=3857#comment-8772 Mark,
Have you seen this post?
Shannon seems to have found a workaround for Fuji.

On checking the syntax, I get the “WARNING Implied eval is evil. Pass a function instead of a string.” error on the setTimeout line, but I also have that error on Eureka, so I am not sure it means much.

]]>
By: Mark Stanger https://servicenowguru.com/client-scripts-scripting/set-default-datetime-picker-dialog-time/#comment-8771 Fri, 03 Apr 2015 15:11:31 +0000 https://servicenowguru.wpengine.com/?p=3857#comment-8771 In reply to Irene.

I’ve looked at this in Fuji and I’m not sure there’s a fix unfortunately. This script depends on being able to listen to the ‘click’ event on that icon. It attaches the listener correctly, but ServiceNow doesn’t seem to be triggering the ‘click’ event on those icons in the same way. You might just have to ask ServiceNow if they have another way to set the default picker time for a particular field.

]]>
By: Irene https://servicenowguru.com/client-scripts-scripting/set-default-datetime-picker-dialog-time/#comment-8770 Fri, 03 Apr 2015 14:00:47 +0000 https://servicenowguru.wpengine.com/?p=3857#comment-8770 I implemented this script last year in Calgary, and it has been working great. However, in Fuji it does not appear to work at all. Any suggestions?
Thanks!

]]>
By: Mark Stanger https://servicenowguru.com/client-scripts-scripting/set-default-datetime-picker-dialog-time/#comment-8769 Fri, 03 Apr 2015 13:52:34 +0000 https://servicenowguru.wpengine.com/?p=3857#comment-8769 In reply to Troy.

Sure. That’s just another element. You should be able to add this line to your script to set that.

$(‘GwtDateTimePicker_ampm’).value = ‘PM’;

]]>
By: Troy https://servicenowguru.com/client-scripts-scripting/set-default-datetime-picker-dialog-time/#comment-8768 Fri, 03 Apr 2015 13:23:00 +0000 https://servicenowguru.wpengine.com/?p=3857#comment-8768 Hi Mark,

That script works great! Thanks for posting that. I’m using a 12 hour format so I need to set the time to 3:00 pm. It’s setting to 3:00, but am. Is there a way to set it to pm? Thanks again for your help.

]]>
By: Anthony https://servicenowguru.com/client-scripts-scripting/set-default-datetime-picker-dialog-time/#comment-8767 Tue, 14 Oct 2014 12:05:00 +0000 https://servicenowguru.wpengine.com/?p=3857#comment-8767 Brilliant Mark!

]]>