How to restrict past date selection in due date field in problem task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Team,
I want to restrict past date selection in due date field in problem task and Change task tables.
I have tried directly in UI Policy, it is working but in form it is showing error, if selected date has passed past date.
Apart from that how can i do this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
UI policy is easiest with no/less script
Another way is to use onChange client script on that field
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
g_form.hideFieldMsg('due_date');
if (newValue != oldValue) {
var RightNow = new Date().getTime();
var end = new Date(g_form.getValue('due_date')).getTime();
if (end < RightNow) {
g_form.clearValue('due_date');
g_form.showFieldMsg('due_date', 'The Due Date cannot be in the past. Please select a future date', 'error', true);
}
}
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
I have used same script it is working last week, now what happening is for problem_task when we select type as "Root Cause Analysis" it is not working. If we select type as "general" some times it is working, sometimes it is not working.
For change_task it is not working at all.
Apart from that I have observed other point as well, I have selected date as today date in due date it is working, I have changed the date to 08/02/2026 this date also it is accepting means it is not throwing any error message.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
so what debugging did you do if it's not working?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Your UI policy should be like this
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I have tried using UI Policy, but what is happening is I have given today date in due date, it is accepting.
If I verify tomorrow, field value is cleared, it is showing error message, not able update the state of that particular record.
users are facing this issue

