Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How I can prevent End date to be less than Start Date using UI Policy

Saif Al-Bashiti
Mega Expert

Hello Expert 🙂 

I have in my table two fields only , a) start date >> b) end date 

I want to prevent user to select end date before start date using UI Policy , always Im searching about best practices , no need for coding here , i think there are Out of the box UI policy to do my goal 

exmaple : 

Start date : 2019 - 2 - 14

end date : 2019 - 2 - 12

here i want to prevent user to enter this invalid value for end date 

thanks 🙂

1 ACCEPTED SOLUTION

joel_ruiz1
Tera Expert

I was able to do this using a onChange client script (See screenshot). Only condition is that you are using date fields and not string fields.

find_real_file.png

 

Hope this helps!

 

-Joel R.

View solution in original post

3 REPLIES 3

Mike Allen
Mega Sage

Generally, this is done in a client script, like this one:

 

/nav_to.do?uri=%2Fsys_script_client.do%3Fsys_id%3D0a6b13db672222004792adab9485ef0e%26sysparm_record_target%3Dsys_script_client%26sysparm_record_row%3D2%26sysparm_record_rows%3D31%26sysparm_record_list%3Dsys_class_name%253Dsys_script_client%255EtableSTARTSWITHchange%255EORDERBYorder

 

There is a method that is used in this script that will help you out.  I wouldn't recreate the wheel by shoving this into a UI Policy.

joel_ruiz1
Tera Expert

I was able to do this using a onChange client script (See screenshot). Only condition is that you are using date fields and not string fields.

find_real_file.png

 

Hope this helps!

 

-Joel R.

i found out the below the hard way:

1) when you use g_form.getValue() in a client script the result is a variable of type STRING

2) so, if your date properties are set to yyyy - mm - dd the date comparison works because it is alphanumeric

    if they are set to dd-mm-yyyy, for example, the comparison fails