function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sanjay92062Sanjay92062 

Visualforce Page redirecting from different Record Types.

Hi,
I have a custom object with two record types. Now i am trying to redirect Visualforce page for one record type.
 Below is my controller code  :
 
public PageReference CaseRedirect() {
       
        	PageReference newPage;
          
            if(m.RecordTypeId =='0000111111'){
                  newPage = new PageReference('/apex/MPage');
                  newPage.getParameters().put('nooverride', '2');
                 return newPage;
                }
        else{
            PageReference pageRef2 = new PageReference('https://test.com/new?count=5&nooverride=1&recordTypeId=00002222');
            return pageRef2;
        }
       
}
Else Condition working as expected, but whenever i selected corrected record type it shows :
Cyclical server-side forwards detected: /apex/MPage
From internet,i added,
newPage.getParameters().put('nooverride', '2');
as well.But i am facing same issue.

Please help me.
Thank you.

 
Best Answer chosen by Sanjay92062
Sanjay92062Sanjay92062
I fixed the above error by creating the different vs page and calling the controller redirect method from there. So it working as expected.

All Answers

ShirishaShirisha (Salesforce Developers) 
Hi Sanjay,

Greetings!

This error occurs if you the page you are referencing here is rediected to the same page on which you are currently.

So,I would suggest you to check if you are using the correct page or not.

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
Sanjay92062Sanjay92062
Hi Shirisha,
Thank you for your reply.
I am using the correct page only. I need to redirect based on Record Type.
I have two record types(A&B) and I wrote a Visualforce page for Record Type A.Whenever i selected Record A from the custom object New button, I want to redirect to A visualforce page.
Whenever selected B record type, it will be the default page.
<apex:page standardController="M" extensions="MController" id="pageId" lightningStylesheets="true" action="{!CaseRedirect}"></apex:page>

Please help me.

 
Sanjay92062Sanjay92062
I fixed the above error by creating the different vs page and calling the controller redirect method from there. So it working as expected.
This was selected as the best answer