- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 08:41 AM
Due Date on Problem task form should be restricted to only 2 months and user should not be able to select past date.
Please guide me on this requirement
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 08:47 AM
you can use 2 UI policies
1) 1st one like this to block past date using UI policy and then use Scripts to show info/error message
OR
use this onChange client script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
g_form.hideErrorBox('end_date');
if (newValue != oldValue) {
var RightNow = new Date().getTime();
var end = new Date(g_form.getValue('end_date')).getTime();
if (end < RightNow) {
g_form.clearValue('end_date');
g_form.showFieldMsg('end_date', 'Planned end date must be after the current date', 'error', true);
}
}
}
2) another UI policy for restricting 2 months -> something similar in the condition
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
03-24-2025 08:47 AM
you can use 2 UI policies
1) 1st one like this to block past date using UI policy and then use Scripts to show info/error message
OR
use this onChange client script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
g_form.hideErrorBox('end_date');
if (newValue != oldValue) {
var RightNow = new Date().getTime();
var end = new Date(g_form.getValue('end_date')).getTime();
if (end < RightNow) {
g_form.clearValue('end_date');
g_form.showFieldMsg('end_date', 'Planned end date must be after the current date', 'error', true);
}
}
}
2) another UI policy for restricting 2 months -> something similar in the condition
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
03-24-2025 08:52 AM
Thank you verymuch @Ankur Bawiskar