On my Opportunity object, I have one Record Type that I am looking to redirect to a custom Visualforce Page & Controller. The other Opportunity Record Types can stay defaulted to the standard page layouts.
I have overriden the Opportunity New Button with the Visualforce below which calls my custom controller.
I receive "Cyclical server-side forwards detected" error when testing.
Any ideas what I am doing wrong?
Visualforce:
<apex:page standardController="Opportunity" extensions="SSPNewOpptyRedirect"
action="{!continueNextPage}">
Apex Class:
public class SSPNewOpptyRedirect {
Opportunity oppty {get; set;}
Id recordTypeA;
public SSPNewOpptyRedirect(ApexPages.StandardController stdController) {
oppty = (Opportunity)stdController.getRecord();
recordTypeA = [SELECT Id
FROM RecordType
WHERE SObjectType = 'Opportunity' AND DeveloperName = 'New_Supply_Side_Platform' LIMIT 1].Id;
}
public PageReference continueNextPage() {
PageReference newPage;
//newPage = Page.SSPOpportunityEdit;
newPage = new PageReference('/apex/SSPOpportunityEdit');
if (Oppty.RecordTypeId != recordTypeA)
{
String retUrl = '006/e';
newPage = new PageReference('/' + retUrl);
}
if (ApexPages.currentPage().getParameters().get('RecordType') != null) {
newPage.getParameters().put('RecordType', ApexPages.currentPage().getParameters().get('RecordType'));
}
if (ApexPages.currentPage().getParameters().get('retURL') != null) {
newPage.getParameters().put('retURL', ApexPages.currentPage().getParameters().get('retURL'));
}
if (ApexPages.currentPage().getParameters().get('ent') != null) {
newPage.getParameters().put('ent', ApexPages.currentPage().getParameters().get('ent'));
}
newPage.getParameters().put('nooverride', '0');
return newPage;
}
}