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 01:44 PM
Yes, it is setting to 20:00 with my script, but users are unable to override it. It is getting locked down.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2018 01:56 PM
you would have to find some way to make it so that the one change script does not run every time it changes. unfortunately oldValue always returns null.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2018 02:18 PM
I thought of something. I created a new checkbox variable and then wrapped my code in an if statement that check if that is true. If it is not it runs and sets that value to true. This will prevent it from running again. It looks like this and then you can use a UI Policy with no conditions to always keep the checkbox variable hidden.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if(g_form.getValue('onchange_datetime_ran') == 'false'){
var dt = newValue.toString().split(' ');
g_form.setValue('AppOps_requested_by_date', dt[0] + ' 20:00:00');
g_form.setValue('onchange_datetime_ran', 'true');
}
}