You need to sign in to do that
Don't have an account?
BobSmith03
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...
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; }
You may want to put some System.debug statements and turn on Debug logging for your user and see if you're getting control in your extension and if the rectype has values as you expect.
Ram
Thanks for reply, Yeah seems like my change is not right. I am redirecting to standard page irrespective of record type. Below is the actual Code, in which we are redirecting to VF page's depending on Record Type.
Controller:
VF Page:
In above code, how can I change existing logic of redirecting to Visualforce page for record type other than "ABC" to redirecting to Standard Account.Edit page for record type other than "ABC"
Thanks again for your time.
Not entirely sure if this will work but worth a try. Also try commenting out the
newPage1.setRedirect(true); line if the following does not work.
if(rt.name != 'ABC')
{
return null; // stays on the same page
} else {
PageReference newPage1 = Page.NonABC_AcctEditLayout;
newPage1.setRedirect(true);
newPage1.getParameters().put('id', recordId);
return newPage1;
}
Ram