You need to sign in to do that
Don't have an account?
SFDC9999
Redirect to visual force Page based on Record Types
Hi,
I have 7 Record Types on Cases and 2 of those record types have to take the user to a Visual force page along with the recordtype selected and the rest of the 5 record types should take the user to a standard case page .
Tried so manby solutions and the pb with all other solutions is record type not setting on the Visual force page which this code does. Any help please
I have 7 Record Types on Cases and 2 of those record types have to take the user to a Visual force page along with the recordtype selected and the rest of the 5 record types should take the user to a standard case page .
public with sharing class CaseOverrideController { private ApexPages.StandardController stdCntrl {get; set;} private Boolean isNew; private Boolean isEdit; private Boolean isView; public CaseOverrideController( ApexPages.StandardController sc ) { stdCntrl = sc; String pageURL = ApexPages.currentpage().geturl(); if( stdCntrl.getId() == null ){ this.isNew = true; }else{ if( pageURL.containsIgnoreCase('/e') || pageURL.containsIgnoreCase('retURL') ){ this.isEdit = true; }else{ this.isView = true; } } } public PageReference redirectPage(){ Schema.DescribeSObjectResult result = Case.sObjectType.getDescribe(); String caseKeyPrefix = result.getKeyPrefix(); Map<String , String> currentPageParam = ApexPages.Currentpage().getParameters(); PageReference pr; if( this.isNew != null && this.isNew ){ pr = new PageReference('/' + caseKeyPrefix + '/e'); }else{ if( [select RecordType.Name from Case where Id = :stdCntrl.getId()].RecordType.Name == 'Core Collection' ){ pr = Page.CC_CaseEdit; }else{ if( this.isEdit != null && this.isEdit ){ pr = Page.CC_CaseEdit; }else{ pr = new PageReference('/' + stdCntrl.getId() ); } } } if( stdCntrl.getId() != null ){ pr.getParameters().put('id', stdCntrl.getId()); } // Copy over parameters for redirect page if( !currentPageParam.isEmpty() ){ pr.getParameters().putAll( currentPageParam ); pr.getParameters().remove('save_new'); } return pr; } }
<apex:page showHeader="true" sidebar="true" StandardController="Case" extensions="CaseOverrideController" action="{!redirectPage}" />I have got it to working a little bit but the If conditions are not right and does not satisy what i am trying to do. And for some reason my standard page keeps loading and never finish loading.
Tried so manby solutions and the pb with all other solutions is record type not setting on the Visual force page which this code does. Any help please
pr.getParameters().put('nooverride', '1');
Thank you for the response. I am able to solve the loading issue now. However i am still struggling with redirecxting to the Visual force page for 2 record types and standrad page for the other 5 record types. DO you see any misatke i am doing in the if conditions
you redirect to CC_CaseEdit page if its 'Core Collection' record type or if its record edit view
and finally to record view page if none of above satisfy.
If you can provide with details on under which condition, which page to load, I should be able to help you.