What is wrong with following event ajax call ffrom form on chanhe od date field

What is wrong with following event ajax call ffrom form on chanhe od date field ?

window.FormAPI.evaluateServerSideExpression(function(fn){
          window.FormAPI.setValue("number41",fn);
},"=calworkdays(FormAPI.getValue("date1").id, FormAPI.getValue("date2").id])");

OriginalPostID-23033

OriginalPostID-23033

  Discussion posts and replies are publicly visible

Parents
  • There's a syntax error in the way you are passing the server-side expression. The evaluateServerSideExpression() function expects a string as it second parameter, however, if you need to get values from the form to be passed as parameters of the server-side expression you need to properly build your string. Right now you are literally passing the phrase: FormAPI.getValue("date1").id instead of the actual value of field. The reason is you made this statment part of the string instead of concatenating it to it. You also have a ] at the end which shouldn't be there.

    Here's the right version of your expression. I tested it and works as expected:

    FormAPI.evaluateServerSideExpression(function(e){window.FormAPI.setValue("number41",e);},"=calworkdays(" + FormAPI.getValue("date1").id + "," + FormAPI.getValue("date2").id +")");
Reply
  • There's a syntax error in the way you are passing the server-side expression. The evaluateServerSideExpression() function expects a string as it second parameter, however, if you need to get values from the form to be passed as parameters of the server-side expression you need to properly build your string. Right now you are literally passing the phrase: FormAPI.getValue("date1").id instead of the actual value of field. The reason is you made this statment part of the string instead of concatenating it to it. You also have a ] at the end which shouldn't be there.

    Here's the right version of your expression. I tested it and works as expected:

    FormAPI.evaluateServerSideExpression(function(e){window.FormAPI.setValue("number41",e);},"=calworkdays(" + FormAPI.getValue("date1").id + "," + FormAPI.getValue("date2").id +")");
Children
No Data