You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Return date validation for a catalog item using onChange script (#1926)
* Create README.md
* Create validateReturndate.js
* Update README.md
Changes to the file:
1. Use case description given.
2. One more example related to another part of the use-case added
This piece of code was written as a part of an usecase where the return date value validation was expected to be after start date as well as within 6 months from the start date. This code runs in an OnChange catalog client script for the field 'u_return_date' and validates the return date(u_return_date) in a ServiceNow Catalog item form to ensure:
2
+
3
+
1. A start date(u_start_date) is entered before setting a return date(u_return_date).
4
+
2. The return date is within 6 months after the start date.
5
+
3. Return date must be after the start date, it can't be same as it or before it.
6
+
7
+
Let’s say with an example:
8
+
9
+
a)
10
+
u_start_date = 2025-10-01
11
+
You enter u_return_date = 2026-04-15
12
+
13
+
Steps:
14
+
a)Difference = 196 days → More than 180 days
15
+
b)Result: u_return_date is cleared and error shown: “Select Return Date within 6 months from Start Date”
16
+
17
+
b)
18
+
u_start_date = 2025-10-02
19
+
You enter u_return_date = 2025-10-01
20
+
21
+
Steps:
22
+
a)Difference = -1 day → Return date put as 1 day before start date
23
+
b)Result: u_return_date is cleared and error shown: “Select Return Date in future than Start Date”
0 commit comments