I have currently overridden the Edit/View/New buttons for the Opportunity object. Everything is working awesome except when I click the "Change" button beside the Record Type. At this point, I am directed to the Record Type selector page, select a new Record Type, and get passed to the edit VisualForce page. At this time the Record Type on the page has not been updated. Please see below the code snippets in play:


<apex:page standardController="Opportunity" extensions="dispatcherOpportunityEditController"  
    action="{!nullValue(redir.url, urlFor($Action.Opportunity.Edit, opportunity.id, null, true))}">


public class dispatcherOpportunityEditController 
    public dispatcherOpportunityEditController(ApexPages.StandardController controller) 
        this.controller = controller;

    public PageReference getRedir() 
        List<Opportunity> oppList = new OpportunitiesSelector().selectById(new Set<Id>{ ApexPages.currentPage().getParameters().get('id') });

        PageReference newPage;

       if (oppList[0].recordtypeid == '012800000007gBQ') 
            newPage = Page.SubscriptionAmendmentEdit;
            newPage = new PageReference('/' + oppList[0].id + '/e');
            newPage.getParameters().put('nooverride', '1');

        newPage.getParameters().put('id', oppList[0].id);
        newPage.getParameters().put('retURL', '/' + oppList[0].Id);
        return newPage.setRedirect(true);

    private final ApexPages.StandardController controller;

Any thoughts would be much appreciated. Thanks!

1 Answer 1


I found the issue. I need to add the following lines:

String recordTypeId = ApexPages.currentPage().getParameters().get('RecordType');
newPage.getParameters().put('RecordType', recordTypeId);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .