name of the script include is : NeedItUtils
isDatePast: function(strDate){
// Create GlideDateTime objects for the current date and the passed in date
var rightnow = new GlideDateTime();
var testdate = new GlideDateTime(strDate);
// If the testdate is before rightnow, return true, else return false
if (testdate.before(rightnow)) {
return true;
}
else {
return false;
}
},
Calling this from another business rules something like this below:
// Instantiate the NeedItUtils class. Call the isDatePast method and pass
// the u_when_needed value.
var niutils = new NeedItUtils();
var isPast = niutils.isDatePast(current.u_when_needed);
// If the isDatePast method returns true, the date is in the past.
if(isPast == true){
gs.addErrorMessage("When needed date cannot be in the past. Your request has not been saved to the database.");
current.setAbortAction(true);
}