Look up script on a DATE field

Austine
Tera Contributor

Hello,

 

Please I need a look up script that will ONLY allow the current or future date to be selected in the date field.

 

Thank you.

3 REPLIES 3

Vishal Birajdar
Giga Sage

Hi @Austine 

 

You can achieve this using Ui policy.

 

Below link might help you.

 

https://www.servicenow.com/community/developer-forum/date-field-to-only-allow-current-date-and-futur...

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Nivedita Patil
Mega Sage
Mega Sage

Hi @Austine ,

 

You can use onChange client script for date field.

 

script for reference:

 

var enteredDate = g_form.getValue('u_glide_date_1');
   var rightNow = new Date().valueOf();
   var datetocheck = new Date(enteredDate).valueOf();
   if(datetocheck < rightNow){
   g_form.addErrorMessage('select the correct date');
   g_form.setValue('u_glide_date_1');
 
Mark my answer correct and helpful if helps you.
 
Thanks,
Nivedita Patil.

Harish Bainsla
Tera Sage
Tera Sage

you can achieve this through ui policy 

https://www.servicenow.com/community/developer-forum/date-field-to-only-allow-current-date-and-futur...

if you get answer please mark helpful and accept solution