- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2023 11:06 PM
Hi,
I have created one check box (u_type) on the change form (change_request table).
(1) If check box is false...planned end date can' be set more than 2 months from planned start date.
(2) If check box is true....Planned end date can't be set more than 6 months from planned start date. if we set less than 6-month, error message should get show.
Can anyone help me on the client script?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2023 12:47 AM - edited 01-27-2023 12:47 AM
Hi @PRAGHATIESH S ,
You can achieve this by UI policy easily, You need to write 2 UI policy for both these condition.
see 1 of the I have created other you can replicate.
Please mark correct if it works for you.
Thanks,
Pratik Malviya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2023 11:28 PM
you can use the solution explained in the below link:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2023 11:31 PM - edited 01-26-2023 11:32 PM
use below snippet :
var gd = new GlideDate();
gd.addMonths(2); // or gd.addMonths(6);
current.u_estimated_time_of_delivery = gd;
var gdt = new GlideDateTime();
gdt.addMonths(2); // or gdt.addMonths(6);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2023 11:36 PM
var startDate = new Date(start);
var endDate = new Date(end);
var diff = endDate.getTime() - startDate.getTime();
var diffInMonths = diff / (1000 * 60 * 60 * 24 * 30);
if (diffInMonths > 2) { gs.addInfoMessage("Error: planned end date cannot be more than 2 months from planned );
Mark helpful or correct.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2023 11:48 PM
Hi @PRAGHATIESH S ,
Did you try with UI policy, it is can very easily be configured in UI policy using filter condition.
No Code date validations through UI Policies
Aman Kumar