Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2025 02:38 AM
new expiry date must be a quarter end dates(mar 31, june 30, sep 30, dec 31) need a date validation on the catalog item variable
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2025 02:51 AM
something like this in onChange client script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Parse the selected date
var date = new Date(newValue);
var month = date.getMonth() + 1; // Months are 0-based in JS
var day = date.getDate();
// Check if the date is a valid quarter-end
var isQuarterEnd = (
(month === 3 && day === 31) ||
(month === 6 && day === 30) ||
(month === 9 && day === 30) ||
(month === 12 && day === 31)
);
if (!isQuarterEnd) {
g_form.showFieldMsg('expiry_date', 'Expiry date must be a quarter end (Mar 31, Jun 30, Sep 30, Dec 31)', 'error');
g_form.clearValue('expiry_date');
} else {
g_form.hideFieldMsg('expiry_date');
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2025 02:51 AM
something like this in onChange client script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Parse the selected date
var date = new Date(newValue);
var month = date.getMonth() + 1; // Months are 0-based in JS
var day = date.getDate();
// Check if the date is a valid quarter-end
var isQuarterEnd = (
(month === 3 && day === 31) ||
(month === 6 && day === 30) ||
(month === 9 && day === 30) ||
(month === 12 && day === 31)
);
if (!isQuarterEnd) {
g_form.showFieldMsg('expiry_date', 'Expiry date must be a quarter end (Mar 31, Jun 30, Sep 30, Dec 31)', 'error');
g_form.clearValue('expiry_date');
} else {
g_form.hideFieldMsg('expiry_date');
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader