Date Validation - client script

Nipan1
Tera Contributor

Hi,

 

I have requirements as below: 

 

1. 'Expected Start Date' should be selected after 7 days from today (if not then show error message and clear the value)

2. 'Expected Completion Date' should be after 'Expected Start Date'. (if not then show error message and clear the value)

 

For the first requirement: I created a UI Policy which is working fine. 

Nipan1_0-1713216476328.pngNipan1_1-1713216496028.png

 

 

For the second requirement:  I created a client script, which is getting Invalid Date from Start date in the script and not working. 

Nipan1_2-1713216633899.pngNipan1_3-1713216686938.png

 

 

Can anyone please help me fix the above issue. 

 

Thanks,

@Nipan1 

 

1 ACCEPTED SOLUTION

Deborah Brown L
Kilo Sage

Hi @Nipan1 ,

For the second requirement also you can create a UI Policy and add the below condition.

DeborahBrownL_0-1713243377883.pngDeborahBrownL_1-1713243413231.png

 

date_2 should be "Expected Completion Date" and date should be "Expected Start Date".

 

Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me.

Regards,
Deborah Brown

View solution in original post

8 REPLIES 8

Hi @Deborah Brown L,

 

I appreciate the solution provided above. The UI policy is indeed effective for me. Thank you.

 

@Nipan1 

Vaibhav20
Tera Contributor

Hi Nipan,

Please follow the link mentioned below as it will be much easier way with no code solution

 

https://www.servicenow.com/community/developer-articles/no-code-date-validations-through-catalog-ui-...

Mark Helpful if resolves your problem

Thanks

Vaibhav20
Tera Contributor

No Code Date Validation 

Try going the above page as it might help you with validating the date fields accurately, may be with no code even

Thanks,

Please mark the post as helpful if it resolves your issue