Date validation

seyio
Tera Contributor

Hi guys,

 

I have a requirement to add planned start date and planned end date to a catalog item. I have used catalog ui policy new feature to add a message where an error message pops up for planned start date cannot be in the past, however for planned end date, this does not work.

condition: planned end date - is more than - 0 hours - after planned start date. error message not popping up an date/time still selectable even when planned start date is not completed.

I would appreaciate guidance with this.

 

 

 

 

1 REPLY 1

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @seyio 

Use the client script:

 

Check this OOTB Client script:

 

https://INSTANCENAME.service-now.com/now/nav/ui/classic/params/target/sys_script_client.do%3Fsys_id%3D307efa93672222004792adab9485ef4f%26sysparm_record_target%3Dsys_script_client

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '')
return;
 
if (typeof validateField === 'function')
validateField('start_date', 'end_date');
else {
var showErrorMsg = function(errorMsg) {
g_form.showErrorBox('end_date', errorMsg);
};
g_form.hideFieldMsg('end_date', true);
if (validateStartDateBeforeEndDate('start_date', 'end_date', showErrorMsg) && (typeof validateMaxDateDuration !== 'undefined'))
validateMaxDateDuration('start_date', 'end_date', showErrorMsg);
}
}

 

https://www.servicenow.com/community/itsm-forum/end-date-greater-than-start-date/m-p/2493307

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************