Disable Past date in Date variable on Record Producer form.

Namita_Snow
Tera Expert

Hi,

 

I have a requirement to add Date field that should only allow user to select future dates, and we used client-side validation to fulfill the requirement. 

 

I would like to know, if there is there any way to disable past date from the Date field, instead of writing client-side validation script.

 

Thanks in Advance!

7 REPLIES 7

Sagar Pagar
Tera Patron

Hi @Namita_Snow,

 

I would suggest to use the Catalog UI policy for data validations instead of Catalog Client scripts.

 

Condition:

Cab date AT OR BEFORE Today

 

Execute if true:

function onCondition() {
g_form.clearValue("date_time_variable");
g_form.showFieldMsg("date_time_variable", "Past date not allowed" , "error");
}

 

For reference:

Screenshot 2023-11-06 at 8.45.56 PM.png

 

If my response helps you resolve your issue. Kindly mark it as helpful & correct. It will be helpful to future readers! 👍🏻
Thanks,
Sagar Pagar

The world works with ServiceNow

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Namita_Snow ,

 

Unfortunately there is no direct configuration for restricting past dates. But u can make use of UI policy where u can do it in such a way

 

DanishBhairag2_0-1699283840683.pngDanishBhairag2_1-1699283952610.png

 

Thanks,

Danish

 

OlaN
Giga Sage
Giga Sage

Hi,

Like Sagar Pagar already mentioned, you can do the validation using a Catalog UI policy, no scripting required.

 

And also, no, there is no way to disable a past date in a date field (that I know of).

Hi @Sagar Pagar , @Danish Bhairag2 and @OlaN ,

Thank you all for your quick replies.

I'm currently using UI policy only. just mentioned it as client-side validation.

 

I wanted to check if it possible to disable date or not. Thanks for clarifying this!!