calculating business days

sonita
Giga Guru

How to calculate business days on a catalog form?

1 ACCEPTED SOLUTION

Soni,



  Add alert in your call back function as shown below and let me know what you see.


    Here is your onChange client script on Needed By   variable:


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


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


  g_form.setDisplay('title', false); // put in the variable name you want to show or hide according needed by date


  return;


  }


  var ga = new GlideAjax('ValidateNeededBy');


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


  ga.addParam('sysparm_needed_by',newValue);


  ga.getXML(callBack);



  function callBack(response) {


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


alert(answer);


  if(parseInt(answer)>=27){


  g_form.setDisplay('title', false); // put in the variable name you want to show or hide according needed by date


  }


  else{


  g_form.setDisplay('title', true); // put in the variable name you want to show or hide according needed by date



  }


  }


}


View solution in original post

23 REPLIES 23

Soni,



  Add alert in your call back function as shown below and let me know what you see.


    Here is your onChange client script on Needed By   variable:


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


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


  g_form.setDisplay('title', false); // put in the variable name you want to show or hide according needed by date


  return;


  }


  var ga = new GlideAjax('ValidateNeededBy');


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


  ga.addParam('sysparm_needed_by',newValue);


  ga.getXML(callBack);



  function callBack(response) {


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


alert(answer);


  if(parseInt(answer)>=27){


  g_form.setDisplay('title', false); // put in the variable name you want to show or hide according needed by date


  }


  else{


  g_form.setDisplay('title', true); // put in the variable name you want to show or hide according needed by date



  }


  }


}


find_real_file.png


if I select today 6/1/2016 it shows 0


if I select   6/2/2016   it shows 9


if I select   6/3/2016 it shows 18


and if I use 24 hour day, M-F, excluding weekends and holidays schedule , it shows , 0 , 24 , 48 ,...


Soni,



  Yes it is working as expected. So what do you want now? If the user selects 6/42016 it should hide the field and if the user selects 6/4/2016, it should show you a filed right?



Thanks,


Abhinay