Apex class:
public class NewAccountExtension {
public String recordTypeId;
public NewAccountExtension(ApexPages.StandardController std) {
}
public Pagereference redirectToNewVFPage(){
Pagereference pg = null;
if(ApexPages.CurrentPage().getParameters().get('RecordType') != null){
recordTypeId = ApexPages.CurrentPage().getParameters().get('RecordType');
if(recordTypeId == Schema.SObjectType.Account.getRecordTypeInfosByName().get('Household').getRecordTypeId()){
pg = new Pagereference('/apex/Page1'); // Add Parameters to Page if Needed
}else if(recordTypeId == Schema.SObjectType.Account.getRecordTypeInfosByName().get('Business').getRecordTypeId()){
pg = new Pagereference('/apex/Page2'); // Add Parameters to Page if Needed
}
pg.setRedirect(true);
return pg;
}
return null;
}
}
Visualforce Page
<apex:page standardController="Account" extensions="NewAccountExtension" action="{!redirectToNewVFPage}">
</apex:page>
Refference:
https://salesforce.stackexchange.com/questions/144499/different-vf-pages-for-different-record-types-on-the-object
No comments:
Post a Comment