How can I make date field to be 3 business days from today's date,selection of any date as less than 3 days, then there should be error message?

namrata15
Kilo Contributor

Do I need to make any script include function?
please reply asap

8 REPLIES 8

You need to use Ajax call to server as explained by ashutoshm1



but in the script include you need to use glideschedule as I mentioned in above post


No need to use glide schedule.



The code above is perfect and runs absolutely fine


Sharique Azim
Mega Sage

Hi Namrata,



Good day.. I suggest to use GlideDate and GlideSchedule together.



A before   business rule .



var abc= current.field_name;


var date= new GlideDate();


date.setValue(abc);




var xyz= gs.nowDateTime();


var date2= new GlideDate();


date2.setValue(xyz);


var dr=gs.dateDiff(date2,date, false);


var val = parseInt(dr);



if(val>2){



var sch = new GlideSchedule('   Your schedule sys_id   ');



if (sch.isInSchedule(date)) {


gs.addInfoMessage("Is in the schedule");


}



else


{


gs.addErrorMessage('Please select a day greater than 3');


current.field_name=date2   //sets todays date


}


}




Please feel free to reach back if you need anything else.



Regards,


Shariq


oharel
Kilo Sage

Hi



I am all for simplicity, so maybe this will help you:


How can I make date field to be 3 business days from today's date?


In the default value of the field, add:


javascript:gs.daysAgo(-3);



Sselection of any date as less than 3 days, then there should be error message?


add an onChange client script:


function onChange(control, oldValue, newValue, isLoading) {


  if (isLoading) {


  return;


  }


  if(newValue < oldValue) {


    alert ('You changed the starting date from ' + oldValue + ' to ' + newValue + " " +'\n' + 'Note that the SLA requires a minimum of 3 days to complete the request.');


  }


}



harel