- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2019 10:50 PM
hi folks,
i have a catalog item varaible with the field type date named "date''
i tried using ui policy but didn't fetch me the results. can you please help me out
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2019 12:04 AM
Hi Vellanki,
You can create a catalog client script onchange to do this. Here is the code and screenshot for reference.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var gdt = new Date(newValue);
var currentDate = new Date();
currentDate.setDate(currentDate.getDate() + 180);
if(gdt>currentDate) {
alert("you cannot select date after 6 months");
}
}
Kindly mark the answer as correct if this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2019 11:00 PM
Hi
Go through the below link :-
https://community.servicenow.com/community?id=community_question&sys_id=15658baddbd8dbc01dcaf3231f961936

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2019 12:04 AM
Hi Vellanki,
You can create a catalog client script onchange to do this. Here is the code and screenshot for reference.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var gdt = new Date(newValue);
var currentDate = new Date();
currentDate.setDate(currentDate.getDate() + 180);
if(gdt>currentDate) {
alert("you cannot select date after 6 months");
}
}
Kindly mark the answer as correct if this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2019 01:28 AM
Hi Vellanki,
Did you try the code that I have shared above? Using catalog client script, you can achieve this.
Mark correct if this works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2019 02:44 AM
hi asifoor,
tq for your response.
well you took 30 days for each month and added 180...but there are some months with 31 and 28 too ..
how to deal with them