Date should not be day before today

Ashish Routray1
Tera Contributor

I have one field called "Extended Date" that date should not be day before today.

So the issue is when i am using any client script and script include for this it reflect in both Native UI and Agent Workspace in My PDI but When I Implement this code in my client instance its is not working.beacuse that case table i am created in customer service scope. 

client script:

field_name:u_extended_date

function onChange(control, oldValue, newValue, isLoading)
{
if(isLoading){ return; }
if(newValue != ''){
var ga = new GlideAjax('CheckDate');
ga.addParam('sysparm_name', 'chkCatDate');
ga.addParam('sysparm_date',g_form.getValue('u_extended_date'));
ga.getXML(DatParse);
}
function DatParse(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
if(answer == 'false'){
g_form.addErrorMessage("Date cannot exist in past.");
g_form.setValue('u_extended_date', ''); // Empty the variable.
}}}

 

Script Include:

var CheckDate = Class.create();
CheckDate.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
chkCatDate : function(){
var start = this.getParameter('sysparm_date');
var currDay = gs.now();
if(start < currDay){
return false;
}
else
{ return true; } } });

6 REPLIES 6

Vaishnavi Lathk
Mega Sage
Mega Sage

HI,

You can do a ui policy as below, simple no code solution

In the script part you can add an alert or something to show the error and clear the field value.

- Vaishnavi

Even i did this same  Ui policies to resolve but it reflect in Native Ui not in Agent workspace.