- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2025 04:39 AM
How to restrict the 'Date' variable in a catalog item to only allow only the 3 month clickable
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2025 08:43 AM
2 approaches
1) you can use catalog UI policy without scripting
2) If you want you can use onChange catalog client script as well
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var selectedDate = new Date(newValue);
var today = new Date();
// Set time to 00:00:00 for accurate comparison
today.setHours(0,0,0,0);
// Calculate max date (3 months from today)
var maxDate = new Date(today);
maxDate.setMonth(maxDate.getMonth() + 3);
if (selectedDate < today || selectedDate > maxDate) {
g_form.addErrorMessage('Please select a date within the next 3 months.');
g_form.clearValue('your_date_variable_name');
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2025 07:58 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2025 07:50 AM
Take a look at this. It may not have 100% what you are looking for but it will have a script include which is what you will need. You may just need to add another function to it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2025 08:43 AM
2 approaches
1) you can use catalog UI policy without scripting
2) If you want you can use onChange catalog client script as well
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var selectedDate = new Date(newValue);
var today = new Date();
// Set time to 00:00:00 for accurate comparison
today.setHours(0,0,0,0);
// Calculate max date (3 months from today)
var maxDate = new Date(today);
maxDate.setMonth(maxDate.getMonth() + 3);
if (selectedDate < today || selectedDate > maxDate) {
g_form.addErrorMessage('Please select a date within the next 3 months.');
g_form.clearValue('your_date_variable_name');
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2025 07:58 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader