I am calling the controller method from action function but it is not getting called from the action function.

Please review the below code.

Visualforce Page

<apex:outputPanel id="hhPageMessage" layout="block" rendered="{!message != null && message != ''}" styleClass="{!'page-msg '+severity+'-msg'}">
                                    <apex:outputText escape="false" value="{!message}" />

<div class="col-sm-6">
                                                <button type="button" class="btn status btn-secondary btn-apply" onclick="openCancelPopup(); return false;">Cancel</button>

<div id="cancelPopup" class="modal-cancel">
                                <div class="modal-content-cancel text-center">
                                    <span class="close" onclick="closeCancelPopup();">&times;</span>
                                    <h4 class="cancel-h4">Are you sure you want to cancel?</h4>
                                    <label class="cancel-label">You cannot continue the same application if you cancel.</label>
                                    <div class="row">
                                        <div class="col-sm-6">
                                            <button type="button" class="btn-secondary cancel" onclick="cancelApp();return false;">Cancel Application</button>
                                            <apex:actionFunction name="cancelInfoApp" oncomplete="callMethod()" action="{!cancelApplication}"  reRender=“cancelInfoApp,hhPageMessage”/>
                                        <div class="col-sm-6">
                                            <button type="button" class="btn-secondary continue-app" onclick="closeCancelPopup()">Continue Application</button>
function cancelApp(){
                console.log('Cancelled Called');

Apex Class

public PageReference cancelApplication(){
        severity = 'error';
            app.Application_Status__c = 'Cancelled';
            app.Cancellation_Date__c = System.today();
            update app;

            ApplicationModel am = new ApplicationModel(app.Id);

            VK 5262020 Email Notification Upon Cancelled Application (EVORP2NJ-140).
            System.debug('Application Cancelled called');
            PageReference pr = new PageReference('EV_MyDashboard');
            return pr;
        }catch(Exception e){
            new ExceptionLogger('EV_IncomeInfoController', 'cancelApplication', app.Id, null, e).createExceptionRecord();
            message = e.getTypeName()+' '+ e.getMessage()+' = '+e.getStackTraceString();
            System.debug('Exception due to====='+e.getMessage()+e.getLineNumber());
            return null;

1 Answer 1


The action function isn't necessary here, you can just:

  class="btn-secondary cancel" 
    Cancel Application

Your original method should work, too, but without an error message, it's difficult to tell why it's not working. Is your apex:actionFunction between an apex:form? That could cause problems if it's not. Context is important here, and we don't have enough of it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .