Issue with Catalog Item Client Script – Inconsistent Date Difference Validation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2025 04:50 AM
Dear Community,
I am reaching out regarding a catalog item that includes a client-side script used to validate the difference between two date fields. The script is intended to ensure that the difference between these dates does not exceed 30 days.
However, we are currently facing an inconsistent behavior. At times, the validation works correctly, while at other times, it does not trigger or allows date differences greater than 30 days without any error message. This issue occurs randomly, making it difficult to identify a clear pattern.
We have checked the script logic, and it appears to be correct.
Below is the client script that is on change
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2025 05:41 AM
Hi @SakshyaR
You can acheive this using UI policy as below.
But still if you want to do this via client srcipt, then please share you script include logic.
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2025 05:41 AM
We would need to see the Script Include function to check that logic as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2025 05:53 AM
Hello,
Share script include function too for better understanding of the issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2025 05:59 AM
It's possibly not working due to date format which will be different for different users.
you can the UI policy based approach as shared by @J Siva and the date format will be handled automatically.
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