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
This piece of 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:
1
+
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
2
3
3
1. A start date(u_start_date) is entered before setting a return date(u_return_date).
4
4
2. The return date is within 6 months after the start date.
5
-
3. Return date is not the start dateor before that.
5
+
3. Return date must be after the start date, it can't be same as it or before it.
6
6
7
7
Let’s say with an example:
8
8
9
+
a)
9
10
u_start_date = 2025-10-01
10
11
You enter u_return_date = 2026-04-15
11
12
12
13
Steps:
13
14
a)Difference = 196 days → More than 180 days
14
15
b)Result: u_return_date is cleared and error shown: “Select Return Date within 6 months from Start Date”
15
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