Custom redirection on Lead Convert operation in salesforce.com

Standard

When you convert a Lead, you will be taken to newly created Account’s detail screen. Thats the standard salesforce.com behaviour.

But what if, you want to show newly created Contact’s detail screen (instead of Account screen), upon Lead conversion? Unfortunately, there is no such setting available in salesforce (yet).

Many people might have achieved it, by some or the other workaround. And here is my trick.

  • Create following Apex Controller class, to use it along with the VF page.
    public class LeadConvertLandingController{
    
        Id newId = null;
        public LeadConvertLandingController(){
            newId = ApexPages.CurrentPage().getParameters().get('newid');
        }
    
        public PageReference redirect(){
            Lead convertedLead = [select ConvertedContactId from Lead where id=:newId];
            PageReference pRef = new PageReference('/' + convertedLead.ConvertedContactId);
            pRef.setRedirect(true);
            return pRef;
        }
    }
    
  • Create a VF page with following markup.
    <apex:page controller="LeadConvertLandingController" action="{!redirect}">
        please wait....
    </apex:page>
    
  • Create a Custom Button for Lead object, as follows:
    • Label = “Convert”.
    • Display type = “Detail Page Button”.
    • Behavior = “Display in existing window without sidebar or header”.
    • Content source = “URL”.
    • And copy below URL in the big text area.
      /lead/leadconvert.jsp?retURL=/{!Lead.Id}&id={!Lead.Id}&saveURL=/apex/LeadConvertLanding
      
  • Now edit the Lead layout and remove the standard Convert button and add the custom Convert button.
  • Thats it!

Hope thats helpful!

Note: This solution works only when, lead conversion is done with new Account/Contact during lead conversion process. It may not work, if existing Account/Contact is chosen, during lead conversion process/screens.

Advertisements