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
Sergio Ruiz BarriosSergio Ruiz Barrios 

Override New Account Button

Hi All,

I want to override the "New" standard button on the Account object with a visualforce in order to avoid the record type selection. I want to redirect it to the Account creation with the Record Type "Nuevo Account". The below code works fine for other object than Account, where it doesn´t load:

VISUALFORCE PAGE

<apex:page standardController="Account" Extensions="testpage" action="{!dotestpage}">
    <apex:form >

    </apex:form>
</apex:page>

APEX CLASS

public class testpage{
 Account acct;
public testpage(apexpages.StandardController stdcontroller){
this.acct=(Account)stdcontroller.getRecord();
}

    public PageReference dotestpage(){
    
    PageReference pageRef = new PageReference('/003/e');
    pageRef.setRedirect(true);
    return pageRef;
    
    }

}

Tanks for the help!
Best Answer chosen by Sergio Ruiz Barrios