logo

NJP

restirction due date is not working in SOW view

New article articles in ServiceNow Community · Feb 16, 2026 · article

Hi,

 

I have written onchange client script, below is my script

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) { if (isLoading || newValue === '') return; if (newValue == oldValue) return; var format = g_user_date_time_format; // or g_user_date_format var dateMs = getDateFromFormat(newValue, format); var selectedDate = new Date(dateMs); selectedDate.setHours(0,0,0,0); var today = new Date(); today.setHours(0,0,0,0); if (selectedDate < today) { g_form.clearValue('due_date'); setTimeout(function() { g_form.showFieldMsg( 'due_date', 'Past dates are not allowed. Please select Today or Future.', 'error' ); }, 100); } else { g_form.hideFieldMsg('due_date'); } }

 

Code is working fine in Native view, when I am working on SOW it is not working.  

 

Field is  due_date and Type is  Date/Time

View original source

https://www.servicenow.com/community/itsm-forum/restirction-due-date-is-not-working-in-sow-view/m-p/3489623#M554429