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

Thank you Abhinay for the response.



Thanks,


Jag.


You are the BEST . It is working fine . sure i will mark your response .



i spent around 2hrs yesterday for this to get it done , but it didnt work


out .



Thank you very much .



On Thu, Sep 15, 2016 at 1:02 PM, abhi_r <community-no-reply@servicenow.com>


This is working great as expected. Thank you very much   abhinay for your help .


Glad I could help. Please mark my response as correct and close the thread.



If you are viewing this from the community inbox you will not see the correct answer button. You need to open the thread directly and you will see a correct answer button with red star.     Please review this How To Mark Answers Correct From Community Inbox


Thanks for navigation . i just marked it   as correct . .



thanks again