- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2025 05:29 AM - edited 04-17-2025 05:34 AM
Hi All,
variable type is Date/Time [ name : Future date ].
Now in catalog form my day should not exceed 60 days,
example [ today is Apr 17th then user should select date before June 15th ]
please help here, how to achieve this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2025 07:15 AM
create onChange client script on that variable
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var selectedDate = new Date(newValue);
var todayDate = new Date(); // Now
todayDate.setDate(todayDate.getDate() + 60);
if (selectedDate.getTime() > todayDate.getTime()) {
alert("Maximum allowed is 30 Days.");
g_form.setMandatory('variableName');
}
}
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
04-17-2025 07:15 AM
create onChange client script on that variable
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var selectedDate = new Date(newValue);
var todayDate = new Date(); // Now
todayDate.setDate(todayDate.getDate() + 60);
if (selectedDate.getTime() > todayDate.getTime()) {
alert("Maximum allowed is 30 Days.");
g_form.setMandatory('variableName');
}
}
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