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
Jay LiladharJay Liladhar 

Redirect Account 'New' button to New lead edit page visualforce

Hi,

I am trying to use VF to redirect to a new lead edit page when clicking on the 'New' button on the Accounts tab.

Not sure how to go about this, please advise.

Thanks,

Jay
Srinath TherampattilSrinath Therampattil
Override the new button on account, with a VF page, which on page load redirects to new lead URL like - /00Q/e?retURL=%2F00Q%2Fo&RecordType=[ID of Record Type if any]&ent=Lead

Thanks,
Srinath
Jay LiladharJay Liladhar
Thanks Srinath, I'm not sure how to add the correct component to enforce the redirect. R, Jay
Srinath TherampattilSrinath Therampattil
Hi Jay,

One way is to use the attribute "action" on the <apex:page> tag, and call your controller method which would redirect to the new lead URL

Page:
<apex:page standardController="Account" extension="CustomClass" action="redirectPage">
.......
</apex:page>

Extension Class:
public class with sharing CustomClass(){
   public PageReference redirectPage() {
      PageReference leadPage = new PageReference('/00Q/e?retURL=%2F00Q%2Fo&RecordType=' + [ID of Record Type if any] + '&ent=Lead');
      leadPage.setRedirect(true);
      return leadPage;
   }
   public CustomClass(){
   }
}

This code is just indicative. Please try and fix any possible issues.

Thanks,
Srinath