Set default time in Date/Time field on catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2018 12:40 PM
I have a date/time variable on a catalog request. I need to set the time default to 20:00:00 when a date is picked and user can update the time if wanted. I tried below script where it is setting the time to 20:00:00 but users are not able to override it. Time is getting locked.
Any thoughts?
Catalog Client Script - OnChange of date/time field
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.setValue('AppOps_Requested_by_date', newValue.replace(/[0-2][0-9]:[0-5][0-9]:[0-5][0-9]$/,"20:00:00"));
//Type appropriate comment here, and begin script below
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2018 12:45 PM
You may want to take a look at this blog post. It is for a script include that give you a lot of the same functionality you see in server side scripting for date / time fields.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2018 12:55 PM
Try this.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var selGdt = new GlideDateTime(newValue);
selGdt.setValue(newValue + " 20:00:00");
g_form.setValue('AppOps_Requested_by_date', selGdt));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2018 01:01 PM
This is still setting to the current time when date is picked.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2018 01:02 PM
I just updated my response, try the updated version. Sorry about that.