- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2019 10:34 AM
hello folks,
please do help me with the requirement
i have a calender field where the user shouldnot select date more than 6months.
i have tried using UI policy but didnt work perfectly.
the client need exactly 6 months.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2019 12:49 AM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var datesplit = (newValue+'').split('-');
var date= new Date(datesplit[2],datesplit[1]-1,datesplit[0]);
var sixmonthdate = new Date();
var day = sixmonthdate.getDate();
sixmonthdate.setMonth(6);
//sixmonthdate.setDate(day+1); for increasing days in the same month
sixmonthdate.setDate(day);
if(date>sixmonthdate)
{
g_form.showFieldMsg('FieldName','You can only request an extension of up to 6 months maximum and cannot be extended on top of the users current expiry date','error');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2019 11:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2019 11:15 PM
You need to use the Client SCript field onChange of the date field. Below is the validation script
var date_Value = newValue;
var gdt = new GlideDateTime(date_Value + " 00:00:00");
gdt.addWeeks(24);
var test = gdt.getDate();
if(dateValue > test) {
gs.print("Beyond");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2019 12:49 AM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var datesplit = (newValue+'').split('-');
var date= new Date(datesplit[2],datesplit[1]-1,datesplit[0]);
var sixmonthdate = new Date();
var day = sixmonthdate.getDate();
sixmonthdate.setMonth(6);
//sixmonthdate.setDate(day+1); for increasing days in the same month
sixmonthdate.setDate(day);
if(date>sixmonthdate)
{
g_form.showFieldMsg('FieldName','You can only request an extension of up to 6 months maximum and cannot be extended on top of the users current expiry date','error');
}
}