past date should not get selected

Rajesh77
Tera Contributor

Hi Team,

 

I have variable (Date/Time) if the user select the past date it should not get selected, only present and future date can be selected

3 REPLIES 3

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Its not possible to prevent one clicking a past date (or make it readonly or something), though you can add validations.

 

This might help you regarding validations:

- 2019-08-12 - Article - No Code date validations thru (Catalog) UI Policies

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Sagar Pagar
Tera Patron

Hi @Rajesh77,

 

You need to write Catalog UI policy with condtions:

 

Date_time_variable BEFORE Today

 

Execute if true:

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

 

Execute if false:

function onCondition() {
g_form.hideFieldMsg();
}

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar

The world works with ServiceNow

Hi @Rajesh77,

 

Have you look into it? Let me know if you stuck and need any help.

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar

The world works with ServiceNow