Validate Past date selection on a field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 11:17 PM
Hi All,
I have a requirement to validate a catalog variable, not to allow user to select any past date. Someone please tell me the working code of it using Client script and Script Include.
Thanks in Advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 11:25 PM
Hi @vartika ,
Try creating an on change client script on this date variable such that you check the difference between current date and the date variable and if the difference is less than 0 then you clear the date variable and display error message stating date shouldn't be a past date.
Please mark this as "Helpful" and "Correct" if this helped you in anyway.
Thanks and Regards,
K. Sai Charan
Sr. ServiceNow Developer
Deloitte India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 11:32 PM
Hi @Sai_Charan_K ,
The basic i know, but the difficulty is user will be having different date format compared to current. If you can provide any working code that will be helpful.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 11:28 PM - edited 09-24-2024 11:35 PM
Hello @vartika
You can achieve this simply with UI policy and no code will be needed.
Please refer the below images and let me know if you have any further questions.
Let me know your views on this and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Regards,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 11:30 PM
Hi @Aniket Chavan,
I have achieved that way but i am not sure that's a good practice to do or not. But with this i also want that using Client script and Script include also.