Past date limitation

abhisek
Tera Contributor

I have a date variable on a catalog item form. User will manually select the date.

I have to set limitation on past date.

Can anyone please help me out.

Thanks in advance.

17 REPLIES 17

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Is it a date field or a date/time field? That is an essential question for using a no-code approach.

 

If going for no code, here's an article I wrote in 2019, still valid:
- 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

Hi @Mark Roethof 

Thanks for your reply. It is a date field.

I have tried with clear value, but the issue is:

If I am raising a request using today's date it is working fine for today but tomorrow it will clear the date field value which was set as today's date.

Hi @abhisek  

 

Have you added the script in false part as well for - If I am raising a request using today's date it is working fine for today but tomorrow it will clear the date field value which was set as today's date.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @abhisek  ,

 

You can simple create a UI policy with condition as

<Your date field > is before <today>

and in advance UI policy script if condition enter the below script.

 

g_form.clearValue(<your date field>);

g_form.addInfoMessage(' past day selection not allowed...');

 

I hope this helps..


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Anubhav24
Mega Sage
Mega Sage

Hi @abhisek  ,

 

Please try below UI Policy , I had worked on a similar requirement  previously , instead of at or before you can use before:

Anubhav24_0-1711707310406.png

 

Anubhav24_1-1711707324900.png

 

 Please mark helpful/correct if my response helped you.