+ Start a Discussion
admin sureshadmin suresh 

I have a scenorio,, while creating a new contact page, if i select a RecordType1 it should redirect to visualforce page and if i select RecordType2 it should go to standard contact page?

sfdcsushilsfdcsushil
Override New button to use vf page. in extension redirect user to standard screen or different vf page based on your requirement. 
admin sureshadmin suresh
NOT WORKING-- Please help me

<apex:page standardController="Contact" extensions="ContactRecordTypePage" action="{!redirectToPage}">
</apex:page>
public class ContactRecordTypePage
{
   private final ApexPages.StandardController controller;
    public ContactRecordTypePage(apexpages.standardcontroller controller)
    {
       this.controller = controller;
    
    } 
    public PageReference redirectToPage() {
        ID id = ApexPages.currentPage().getParameters().get('RecordTypeID');
        system.debug(id);
       if (id == '01290000001AnHy')
       {
           PageReference p = new PageReference('003/e?retURL=%2F003%2Fo&RecordType=01290000001AnHy&ent=Contact');
           p.setRedirect(true);
           return p;
        }
             //return Page.RehireBadgeOnly.setRedirect(true);
      else
      {
        // return new PageReference('/003/e?retURL=%2F003%2Fo');
         
           PageReference p1 = new PageReference('003/e?retURL=%2F003%2Fo&RecordType=01290000001AnII&ent=Contact');
           p1.setRedirect(true);
           return p1;
        
        //return null;
       }
       return null;
    }

}