How to set only the future dates to variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2018 03:14 AM
Hi,
I have a field called "Expected order delivery date" , it means this date field should be made to select only today's and future days, its should be restricted to select the Past dates. How can i change this only for one catalog item variable to select the future dates.
Can someone please help me here.
- Labels:
-
Service Catalog
-
Service Portal
-
Workflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2018 03:26 AM
I have write this code on Incident table to accept only today's and future days,
// Script Include //
var IncidentOccurence = Class.create();
IncidentOccurence.prototype = Object.extendsObject(AbstractAjaxProcessor, {
date : function()
{
var clientDate = this.getParameter('sysparm_todaysDate');
var currentDate = gs.nowDateTime();
var a = gs.dateDiff(currentDate,clientDate,true);
gs.log('datediff is'+ a);
if( a > 0)
{
return 'wrong' ;
}
else
{
return 'right' ;
}
},
type: 'IncidentOccurence'
});
// Client script //
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('IncidentOccurence');
ga.addParam('sysparm_name', 'date');
ga.addParam('sysparm_todaysDate', g_form.getValue('u_date'));
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if(answer == "wrong")
{
g_form.clearValue('u_date');
g_form.setMandatory('u_date' , true);
alert('Please enter the past and today date only');
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2018 04:21 AM
you can make it more simple
create catalog ui policy and put the condition like screenshot below.
condition would be like <data variable> | Before | Today
then put the alert in "execute if true" section and g_form.clearValue('<date variable name>')
Note: Now you will only be able to select future and current date.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2018 04:51 AM
Hi Harsha,
I have tried this and it is not working...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2018 04:54 AM
can you share the screenshot of your ui policy.
because i have used this and it worked perfectly fine