+ Start a Discussion
Srinivas223Srinivas223 

could someone tell me what I am missing here. Error:Cyclical server-side forwards detected: /apex/OppRecordTypeSelection

For a particular record type on Opportunity, I want to redirect the new button to a visualforce and the rest of the recordtypes to standard page layouts. 
Controller
public with sharing class Demo_EXT{
public PageReference pageRef;

public Opportunity opp;

    public Demo_EXT(ApexPages.StandardController myController){
        this.opp = (opportunity)myController.getRecord();
    }

    public PageReference Redirect() {
   // pageRef = new PageReference();
        If(opp.recordtypeId == '0120O000000L6Ve'){
            system.debug('----'+ opp.recordtypeid);
            pageRef = new PageReference('/apex/OppRecordTypeSelection');
            return pageRef;
        }
        else
           
        return null;
    }
}

VF Page
<apex:page standardcontroller="Opportunity"  extensions="Demo_EXT" action="{!redirect}">
<apex:messages />
   
    <apex:form >
        <apex:pageblock mode="edit" title=" Edit">
            <apex:pageblockbuttons >
                <apex:commandbutton value="Save" action="{!Save}"/>
                <apex:commandbutton value="Cancel" action="{!Cancel}"/>
            </apex:pageblockbuttons>
                <apex:pageblocksection title="Information" showheader="true" columns="2">
                    <apex:inputfield value="{!Opportunity.Name}"/>
                    <apex:outputfield value="{!Opportunity.OwnerId}"/>
                    <apex:inputfield value="{!Opportunity.closeDate}" required="false"/>
                    <apex:inputfield value="{!Opportunity.stagename}" required="false"/>
                    
                    <apex:pageblocksectionitem />
                </apex:pageblocksection
            </apex:pageblock>
    </apex:form>
</apex:page>

I appreciate your help.

Thank you!
Best Answer chosen by Srinivas223
Raj VakatiRaj Vakati
You are calling Redirect method on the Page Load Action action="{!redirect}" to the same page "OppRecordTypeSelection" 

All Answers

Raj VakatiRaj Vakati
You are calling Redirect method on the Page Load Action action="{!redirect}" to the same page "OppRecordTypeSelection" 
This was selected as the best answer
Raj VakatiRaj Vakati
public with sharing class Demo_EXT{
public PageReference pageRef;

public Opportunity opp;

    public Demo_EXT(ApexPages.StandardController myController){
        this.opp = (opportunity)myController.getRecord();
    }

    public PageReference Redirect() {
   // pageRef = new PageReference();
        If(opp.recordtypeId == '0120O000000L6Ve'){
            system.debug('----'+ opp.recordtypeid);
            pageRef = new PageReference('/apex/OtherPage');
            return pageRef;
        }
        else
           
        return null;
    }
}