Catalog UI Policy - end date cannot be before start date

Bird Petcharayu
Kilo Contributor

Hello,

I need help. I am trying to use Catalog UI Policy to set the condition on the end date field. What I need is the end date cannot be before start date.

The field is "date" not "date/time"

I applied the condition as below for "end_date_of_visit" is more than 0 days after "starting date of visit" and use the client script BUT it doesn't work. The end date of visit field still can fill in the date before starting date.

 

Not sure that for this case, it's wrong on the condition I set or from the client script ?

 

find_real_file.png

 

find_real_file.png

1 ACCEPTED SOLUTION

Aman Singh_
Kilo Sage

Hi,

 

Have you tried an alternative with the onchange client script on end_date.

function onChange(control, oldValue, newValue, isLoading) {


  if (isLoading || newValue == '') {


  return;


  }

 var dFormat = g_user_date_format;

var end = getDateFromFormat(g_form.getValue('end_date'),dFormat);
var sDate=getDateFromFormat(g_form.getValue('start_date'),dFormat);

if(end<sDate)


  {


  alert(getMessage("End date should not be before Start date"));


  g_form.setValue('end_date','');



  }


  


 



  }

Please mark Correct✅/helpful???? if applicable, thanks!!

Aman

View solution in original post

20 REPLIES 20

Thanks for this! It's such a simple solution that doesn't require using a script include, etc. I was having the same issue with client script date comparisons not working properly, and this worked perfectly! The only thing I had to do was use "g_user_date_time_format" instead because mine was a date/time field.

Aman Singh_
Kilo Sage

You can use the no-code approach to validate start date should not be before today

Create a UI policy as 

find_real_file.png

find_real_file.png

Appreciate, it's workable.

Glad to help!!,

 

Please mark the appropriate answer as correct and close the thread.

 

Thanks,

Aman

Found 1 thing that maybe tricky. it seems still be able to avoid UI policy if enter the end date first and start date later. It's allowed to input.

Do we have a script to validate the form ?

 

find_real_file.png