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
BobSmith03BobSmith03 

Need to redirect to VF page or Standard page based on Record Type

In Sales App, we have written Customized pages for Account View & Edit. Now we got requirement to redirect page to Standard Account edit page based on record type. I mean if Record type is "ABC" goto Account_EDIT_VF page else goto Standard Salesforce Account Edit page.

I have tried below changes, but I am breaking existing logic. For both record types, page is redirecting to Standard Edit page. Please suggest corrections...Thanks for your time.

 

PAGE:

<apex:page standardController="Account" id="AccPage" showHeader="true" tabStyle="account" extensions="AcctEditController" action="{!nullvalue(null, urlFor($Action.Account.edit, Account.id,[retURL=URLFOR($Action.Account.view, Account.id,null,true)], true))}"> <style>

 

 

Controller:

 

if(rectype.name=='ABC')
{
return null; 
} else {
PageReference newPage1 = new PageReference('/' + recordId + '/e');
newPage1.setRedirect(true);
newPage1.getParameters().put('nooverride', '1');
return newpage1;
}

 

ManojjenaManojjena

In account new button just override ur record type selection vf page  and dynamically display all record type in that page ,In that page controller check contion with the ppick list value.and redirect to different page .From that controller you can redirect to standrad page also.

akzeakze

In your controller, put a method which returns the page to which system need to redirect to:
action="{!doRedir}"

In doRedir method, check conditions, and based on that return the page or return the null to stay on the current page.