how to check , date and time entered by user is 48hours from the current time .

vijaysirangi
Kilo Contributor

find_real_file.png

please post if any one has the script for it .

1 ACCEPTED SOLUTION

Please check your instance. I have created a new onchnage client script and script include. It is working as expected.


onChange:


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


  if (isLoading || newValue == '') {


  return;


  }


  var ga = new GlideAjax('ValidateDate');


  ga.addParam('sysparm_name','dateValidation');


  ga.addParam('sysparm_date',newValue);


  ga.getXML(CallBack);



  function CallBack(response) {


  var answer = response.responseXML.documentElement.getAttribute("answer");


  if(answer=='true'){


  alert("pls select atleast 48hrs or more   from now");


  g_form.setValue('lpar_refreshed','');


  }


  }


}


Script include:


var ValidateDate = Class.create();


ValidateDate.prototype = Object.extendsObject(AbstractAjaxProcessor, {


  dateValidation: function(){


  return (gs.dateDiff(gs.nowDateTime(),new GlideDateTime(this.getParameter('sysparm_date')), true)/3600<48);


  },


  type: 'ValidateDate'


});


View solution in original post

27 REPLIES 27

Abhinay Erra
Giga Sage

Thank you


vijaysirangi
Kilo Contributor

we have to exclude weekends from it . if user is placing request on friday evng then it should not accept saturday and sunday . tuesday evng it should accept .



thanks


Hello Vijay,



Are you able to achieve this requirement excluding weekends from the calendar.



Thanks,


Jag.