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
AyanHoreAyanHore 

Passing id in edit button VF page override

Hi,

I'm working on a custom object which requires me to replace the standard edit page of the same with a VF page. Once the "Edit" button is clicked on the detail page (Salesforce standard detail page), it should redirect to the VF page.

However, I require the id of the object to be passed as a parameter to the VF page.

I'm able to override the "Edit" button with the VF page, but not able to pass the Id as a parameter. As a result, it is not working properly for me.

If anyone can point me in the right direction on how to do this, will be very helpful..!!

Regards,
~Ayan
Best Answer chosen by AyanHore
Nilesh Jagtap (NJ)Nilesh Jagtap (NJ)
You can use extension controller to get Id of record
Here is the sample code for your refernce :
// myControllerExtension will be used as extension along with StanderdController on your vf page

public class myControllerExtension {

     public Account acct{get;set;}
     public string accId {get;set;}

    // The extension constructor initializes the member
    // variable acct by using the getRecord method from the standard
    // controller.
    public myControllerExtension(ApexPages.StandardController stdController) {
        this.acct = (Account)stdController.getRecord();
        accId = acct.id;
    }

    public void saveRecord() {
       // code to update your record
    }
}


Thanks,
N.J