2

Could you help me to check my error? I have problem when i save my visualforce, I get Error like this :

Unknown method 'functionCountSeverence.RunSeverence()'

I was declare my class with : public with sharing class functionCountSeverence(){}

But, I still get the errorm. Here My Visualfprce page code :

<apex:page controller="functionCountSeverence">
    <apex:form >
        <apex:pageBlock title="Severence">
            <apex:pageBlockSection columns="1" showHeader="false" >
             <apex:commandButton id="RunPreProcess" value="Process Severence"
                                    onclick="return confirm('Are you sure to process this Severence ?');"
                                    action="{!RunSeverence}"
                                    />    
            </apex:pageBlockSection>               
        </apex:pageBlock>
    </apex:form>
</apex:page>

And This is my Class controller code :

public with sharing class functionCountSeverence {

    //Declare Variable:
    Public Date vPaymentStartDate;
    public Date vSalaryStartDate;
    public Date vSalaryEndDate;
    public Id   VFLDEmpElmHeaderId;
    public Id   VFLDEmpElmHeaderEmpNo;

    //MAP Declaration :
    Map<String,PYRESYTDHEADER__c> PYRESYTDHEADERMap = new    Map<String,PYRESYTDHEADER__c>();    

    public string RunSeverence(String selectedPayrollName, Boolean ProcessAll, SelectOption[] selectedEmployee, String selectedPackage)
    {
        string message;
        //===================================== Get Salary Start Date and Salary End Date from SETPERIOD ======================================
        //Query from Payroll Period to Get Record for Employee Element by Period
        PYSETPAYPERIOD__c[] VFLDQPayPeriod = [SELECT Salary_Start_Date__c, Salary_End_Date__c, Payment_Start_Date__c
                                              FROM PYSETPAYPERIOD__c WHERE Id=:selectedPayrollName]; 

        PYSETPAYPERIOD__c eSinglePayPeriod = new PYSETPAYPERIOD__c();
        for (PYSETPAYPERIOD__c VFLDLSTPayPeriod : VFLDQPayPeriod)
        {
            eSinglePayPeriod = new PYSETPAYPERIOD__c();
            vPaymentStartDate   = VFLDLSTPayPeriod.Payment_Start_Date__c;
            vSalaryStartDate    = VFLDLSTPayPeriod.Salary_Start_Date__c;
            vSalaryEndDate      = VFLDLSTPayPeriod.Salary_End_Date__c;
        }
        //=================================== End Get Salary Start Date and Salary End Date from SETPERIOD ====================================== 
        //-----PYEMPELEMENTHEADER__c (Employee Header)
        LIST <PYEMPELEMENTHEADER__c> VFLDQPYEMPELEMENTHEADER = [SELECT Assignment_No__c, Company_Name__c, Cost_Center_Code__c, Employee_No__c, 
                                                                Employee_No__r.Full_Name__c, Employee_No__r.Effective_Date__c, Grade_Name__c, 
                                                                Job_Title_Name__c, Organization_Name__c, Payment_Start_Date__c,Period__c, 
                                                                Period__r.Name, Position_Name__c, Package_Name__c, Tax_File_No__c,
                                                                Tax_Location_Name__c, Tax_Location_Name__r.UMP_Limit__c, Employee_No__r.Name, Tax_Status__c, 
                                                                Tax_Type__c, Work_Location_Name__c, Id, Employee_No__r.Full_Name__r.Gender__c, 
                                                                Employee_No__r.Full_Name__r.Marital_Status__c , Is_Severence_Pay__c
                                                                FROM PYEMPELEMENTHEADER__c 
                                                                WHERE Period__c =: selectedPayrollName
                                                                AND Package_Name__c =: selectedPackage AND Payment_Start_Date__c =: vPaymentStartDate 
                                                                ORDER BY Payment_Start_Date__c, Employee_No__c];

        //-----PYRESYTDHEADER__c (YTDH) Table 
            String vCurrentYear     = String.valueOf(vPaymentStartDate.year());
            LIST <PYRESYTDHEADER__c> VFLDLSTQPYRESYTDHEADER = [SELECT Employee_No__c FROM PYRESYTDHEADER__c
                                                                       WHERE Current_Year__c=:vCurrentYear];
        for(SelectOption VFLDLSTSlcEmpList : selectedEmployee)
        {
            Id  VFLDSelEmpVal   =   VFLDLSTSlcEmpList.getvalue();

            for (PYEMPELEMENTHEADER__c VFLDPYEMPELEMENTHEADERList : VFLDQPYEMPELEMENTHEADER)
            {
                VFLDEmpElmHeaderEmpNo   = VFLDPYEMPELEMENTHEADERList.Employee_No__c;                
                if(VFLDSelEmpVal == VFLDEmpElmHeaderEmpNo)
                {
                    String vYear            = String.valueOf(date.valueOf(VFLDPYEMPELEMENTHEADERList.Payment_Start_Date__c).Year());
                    String KeyId            =  vYear+ VFLDPYEMPELEMENTHEADERList.Employee_No__c;
                    Integer vCurrentPeriod  = VFLDPYEMPELEMENTHEADERList.Payment_Start_Date__c.Month()-VFLDPYEMPELEMENTHEADERList.Payment_Start_Date__c.Month() + 1;
                    PYRESYTDHEADERMap.put(KeyId, new 
                              PYRESYTDHEADER__c(
                                  Company_Name__c            = VFLDPYEMPELEMENTHEADERList.Company_Name__c,
                                  Cost_Center_Code__c        = VFLDPYEMPELEMENTHEADERList.Cost_Center_Code__c,
                                  Current_Month__c           = VFLDPYEMPELEMENTHEADERList.Payment_Start_Date__c.Month(),
                                  Current_Period__c          = vCurrentPeriod,
                                  Current_Year__c            = String.valueOf(VFLDPYEMPELEMENTHEADERList.Payment_Start_Date__c.Year()),
                                  Effective_Month__c         = VFLDPYEMPELEMENTHEADERList.Payment_Start_Date__c.Month(),
                                  Employee_Name__c           = VFLDPYEMPELEMENTHEADERList.Employee_No__r.Full_Name__c,
                                  Employee_No__c             = VFLDPYEMPELEMENTHEADERList.Employee_No__c,
                                  Gender__c                  = VFLDPYEMPELEMENTHEADERList.Employee_No__r.Full_Name__r.Gender__c,
                                  Grade_Name__c              = VFLDPYEMPELEMENTHEADERList.Grade_Name__c,
                                  Is_Severence_Pay__c        = VFLDPYEMPELEMENTHEADERList.Is_Severence_Pay__c,
                                  Job_Title_Name__c          = VFLDPYEMPELEMENTHEADERList.Job_Title_Name__c,
                                  Organization_Name__c       = VFLDPYEMPELEMENTHEADERList.Organization_Name__c,
                                  Position_Name__c           = VFLDPYEMPELEMENTHEADERList.Position_Name__c,
                                  Tax_File_No__c             = VFLDPYEMPELEMENTHEADERList.Tax_File_No__c,
                                  Tax_Location_Name__c       = VFLDPYEMPELEMENTHEADERList.Tax_Location_Name__c,
                                  Tax_Status__c              = VFLDPYEMPELEMENTHEADERList.Tax_Status__c,
                                  Tax_Type__c                = VFLDPYEMPELEMENTHEADERList.Tax_Type__c,
                                  Work_Location_Name__c      = VFLDPYEMPELEMENTHEADERList.Work_Location_Name__c

                                ));
                }
            }
        }
        //-------------------------------------Validation for Check Duplicate record on YTDH--------------------------------------------------        
                LIST <Id> VFLDSTYTDHDelId = new LIST<Id>();

                for(SelectOption VFLDLSTSlcEmpList : selectedEmployee)
                {
                    Id  VFLDSelEmpVal   =   VFLDLSTSlcEmpList.getvalue();
                    for(PYRESYTDHEADER__c VCompareYTDList : VFLDLSTQPYRESYTDHEADER)
                    {
                        if(VFLDSelEmpVal == VCompareYTDList.Employee_No__c)
                        {
                            String TempId = String.valueOf(VCompareYTDList.Id);
                            VFLDSTYTDHDelId.add(TempId);                            
                        }
                    }
                }

                LIST<PYRESYTDHEADER__c> VFLDYTDHDelete = [SELECT Id FROM PYRESYTDHEADER__c WHERE Id IN:VFLDSTYTDHDelId];

                Integer CountUpdEmpElm = VFLDYTDHDelete.size();

                if(CountUpdEmpElm != 0)
                {
                    delete VFLDYTDHDelete;
                }

                //Insert to PYEMPELEMENT__c table:
                insert PYRESYTDHEADERMap.values();
            //============================================ END PROCESS INSERT TO YTDH ===============================================                
        return message;
    }   

}
5

Methods that have parameters can't be called from Visualforce. Instead you have to set fields of the controller class using one or more apex:param tags nested inside the apex:commandButton tag and make the action method a method that accepts no arguments (but references the fields of the controller).

See e.g. Passing Parameters with a Commandbutton for an example.

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.