I am overriding the case select Record Type page. The page shud redirect to a custom VF page if selected record type is 'Support' else to the standard Case page
VF Page :
<apex:page StandardController="Case" extensions="NtnxNewCaseRecordTypeEXT" standardStylesheets="true" showHeader="true" tabStyle="Case">
<apex:form >
<apex:pageBlock tabStyle="Case" title="Select Record Type">
<div>
<apex:selectList id="recordTypeDropDown" value="{!selectedVal}" multiselect="false" size="1">
<apex:selectOptions value="{!recordTypeSelectList}"></apex:selectOptions>
</apex:selectList>
</div>
<apex:outputPanel ></apex:outputPanel>
<div align="center">
<apex:outputPanel >
<apex:commandButton id="Continue" Value="Continue" action="{!redirectCaseCreationPage}"/>
<apex:commandButton id="Cancel" Value="Cancel" action="{!customCancel}"/>
</apex:outputPanel>
</div>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class NtnxNewCaseRecordTypeEXT{
public List<SelectOption> recordTypeSelectList{get;set;}
public string selectedVal{get;set;}
private ApexPages.StandardController controller = null;
public String supportRecordTypeId;
public String prefix;
public NtnxNewCaseRecordTypeEXT(ApexPages.StandardController controller){
this.controller = controller;
Map<String,Schema.RecordTypeInfo> rtMapByName = new Map<String,Schema.RecordTypeInfo>();
prefix = Case.SObjectType.getDescribe().getKeyPrefix();
Schema.DescribeSObjectResult caseDescribe = Schema.SObjectType.Case;
rtMapByName = caseDescribe.getRecordTypeInfosByName();
system.debug('******rtMapByName******' + rtMapByName);
recordTypeSelectList = new List<SelectOption>();
for(String rt: rtMapByName.keySet()){
recordTypeSelectList.add(new SelectOption(rtMapByName.get(rt).getRecordTypeId(),rt));
if(rt == 'Support')
supportRecordTypeId = rtMapByName.get(rt).getRecordTypeId();
}
}
public pageReference redirectCaseCreationPage()
{
system.debug('****SELECTED VAL ******:' + selectedVal);
String retURL = 'ent=Case&RecordType='+selectedVal;
if(selectedVal == supportRecordTypeId){
return new PageReference('/apex/Ntnx_New_Case?'+retURL);
}
else{
system.debug('******prefix*********:' + prefix );
return new PageReference('/500/e?' + retURL );
}
}
public pageReference customCancel()
{
return new PageReference('/'+prefix +'/o');
}
}
It above code is working fine for Support but for all other record type it does not go /500/e?
instead i see the following URL
/apex/Ntnx_New_Case_RecordType?save_new=1&sfdc.override=1