I'm using the actionFunction to call a method to create payments from my visualforce page. The thing that changes is the payment type (sometimes its cash sometimes its check and sometimes both). The problem occurs when i try any type of payment that is not both cash and check (meaning i don't use all the parameters)

my actionFunction:

<apex:actionFunction action="{!createPayments}" name="finishPaymentActionFunction" reRender="showstate">
    <apex:param id="cashAmount" name="cashAmount" value="" />
    <apex:param id="checkAmount" name="checkAmount" value="" />
    <apex:param id="bankParam" name="bankParam" value="" />
    <apex:param id="branchParam" name="branchParam" value="" />
    <apex:param id="serialParam" name="serialParam" value="" />
    <apex:param id="checkDateParam" name="checkDateParam" value="" />

my javascript function:

function validatePayment() {
    var cashAmountField = parseFloat($('#cashAmountField').val());
    var checkAmountField = parseFloat($('#checkAmountField').val());
    var checkBankField = $('#checkBank').val();
    var checkBranchField = $('#checkBranch').val();
    var checkSerialField = $('#checkSerial').val();
    var checkDateField = $('#checkDate').val();

    return true;

The createPayments method has a debug message at the beginning of it so i know when it is getting called. It only gets logged when i have all parameters with values, if i call the method with any of the parameters empty it doesn't log (meaning it doesn't get called). What am i missing?

  • 1
    It seems there is some issue in the calling of the JavaScript function created by apex:actionFunction. Please check if you are getting any JavaScript error in the browser console.
    – Saroj Bera
    Jul 10 '18 at 11:48
  • Yes, it was indeed an issue in the javascript, thanks for the help :)
    – RealGigex
    Jul 10 '18 at 11:57

I found the issue, it was a section in the javascript that i did not include which was returning false causing the method to not be called.


I think you have to use the parameter, assignTo="{!nameOfVariableInApexClass}", to pass the value from visualforce page to Apex class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.