Set default time in Date/Time field on catalog

S_53
Kilo Guru

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
}

12 REPLIES 12

Thanks, but no luck. it still sets the current time.

 

Brian Lancaster
Tera Sage

So are you trying to make it so as soon as the click on the calendar picker it defaults the time to 20:00:00.

find_real_file.png

Brian Lancaster
Tera Sage

Try this it worked for me.

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}
	
	//Type appropriate comment here, and begin script below
	var dt = newValue.toString().split(' ');
	g_form.setValue('AppOps_requested_by_date', dt[0] + ' 20:00:00');
}

Not sure if I am missing something here.

 

My updated Script as suggested: 

find_real_file.png

 

It is setting the current time:

find_real_file.png

You have to have a space before the 2 (" 20:00:00").