- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2024 08:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2024 07:07 AM
Hi @Siddiqbasha ,
Please try the below in UI policy:
In the Script section:
function onCondition() {
g_form.clearValue('start_date');
g_form.showFieldMsg('start_date', 'Selected Planned start date cannot be more than 4 days!', 'error', true);
}
Result:
When more than 4 days selected:
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2024 02:58 AM
Hi @Siddiqbasha
Instead of doing this, better out a UI policy that the start date can be greater than 4 days and if user select more than 4 days show a message, that is easy and quick.
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]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2024 11:10 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2024 08:01 AM
Hello @Siddiqbasha
In ServiceNow, disabling specific dates directly within the calendar picker isn’t supported without using DOM manipulation, which isn’t recommended. However, you can achieve similar functionality by setting up a UI Policy and UI Policy Action to validate the date selection.
Here's how:
- Create a UI Policy that runs on form load or on change of the start_date field.
- In the UI Policy Action, configure a condition to check if the selected date is outside the allowed four-day range.
- If an invalid date is selected, clear the date field or display an error message.
This approach requires little to no code and keeps the setup manageable within ServiceNow’s best practices.
*************************************************************************************************************
"If you found my answer helpful, please give it a like and mark it as the "accepted solution". It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-09-2024 07:07 AM
Hi @Siddiqbasha ,
Please try the below in UI policy:
In the Script section:
function onCondition() {
g_form.clearValue('start_date');
g_form.showFieldMsg('start_date', 'Selected Planned start date cannot be more than 4 days!', 'error', true);
}
Result:
When more than 4 days selected:
Mark this as Helpful / Accept the Solution if this helps.