function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sakti Sahoo 5Sakti Sahoo 5 

error on defining custom action method in <commandButton> tag

Hi,

I am getting error like this : Unknown method 'Incident__cStandardController.SaveRecord()'

Below is my code:
*************************


Apex Page :
******************
<apex:page standardController="Incident__c" extensions="IncGetParmAdminClass" sidebar="false" showHeader="false">
.....
.....
.....

<apex:commandButton value="Submit" action='{!SaveRecord}'/>

Apex Class:
*******************
public class IncGetParmAdminClass
{
  Public Incident__c param {get; set;}
  private ApexPages.StandardController standard_Controller;
    public IncGetParmAdminClass(ApexPages.StandardController standard_Controller)
    {
        param = new Incident__c();
        .................
       ..................
      public PageReference SaveRecord(){
            insert param;
            
            return null; 
        }


For some of my earlier requerement, I have done in the same way and it is working perfect. but for the above senario, I am getting error like this. 
Am I doing any mistake on declaring custom action name inside standard controller page tag. Please help me out.

Thanks in advance.
SAKTI


 
Best Answer chosen by Sakti Sahoo 5
Sakti Sahoo 5Sakti Sahoo 5
Thanks Shyama & Alexander for your reply. 
The issue that I was getting here for missing curly bracket "}" in my apex class.

Here I modified.

public class IncGetParmAdminClass
{
  Public Incident__c param {get; set;}
  private ApexPages.StandardController standard_Controller;
    public IncGetParmAdminClass(ApexPages.StandardController standard_Controller)
    {
        param = new Incident__c();
        .................
       ..................
} // Here I missed it.

      public PageReference SaveRecord(){
            insert param;
            
            return null; 
        }

Thanks Again. Hope your support going forward. :)
-SAKTI

All Answers

Shyama B SShyama B S
Hi Sakti,
Is incident__c is a controller? I am assuming that "IncGetParmAdminClass" is your custom controller.
Please try replacing the first line of apex page to the below and let me know if you face any issues:
<apex:page Controller="IncGetParmAdminClass" sidebar="false" showHeader="false">
Thanks
Alexander TsitsuraAlexander Tsitsura
Hi Sakti,

Everything looks good, can u share all extension code?

Thanks,
Alex
Sakti Sahoo 5Sakti Sahoo 5
Thanks Shyama & Alexander for your reply. 
The issue that I was getting here for missing curly bracket "}" in my apex class.

Here I modified.

public class IncGetParmAdminClass
{
  Public Incident__c param {get; set;}
  private ApexPages.StandardController standard_Controller;
    public IncGetParmAdminClass(ApexPages.StandardController standard_Controller)
    {
        param = new Incident__c();
        .................
       ..................
} // Here I missed it.

      public PageReference SaveRecord(){
            insert param;
            
            return null; 
        }

Thanks Again. Hope your support going forward. :)
-SAKTI
This was selected as the best answer