You need to sign in to do that
Don't have an account?

Redirect to different VF pages based on record Types & Users
Hi ,
I am currently trying to redirect users to various pages based on record types and Internal user vs community users. I have the intial part working where i have redirecting based on Internal user and external user .
To do : For Internal user redirect to a VF called CC_CaseEdit for Record types A, B , C and for Record Types D,E,F take them to stanard New Page
I am currently trying to redirect users to various pages based on record types and Internal user vs community users. I have the intial part working where i have redirecting based on Internal user and external user .
To do : For Internal user redirect to a VF called CC_CaseEdit for Record types A, B , C and for Record Types D,E,F take them to stanard New 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; User u = [SELECT id, Contact.Account.Id FROM User WHERE Id = :UserInfo.getUserId()]; if(u.Contact.Account == null){ //If Internal user if( this.isNew != null && this.isNew ){ // Need to add Record type conditions here pr = new PageReference('/' + caseKeyPrefix + '/e'); }else{ if( this.isEdit != null && this.isEdit ){ pr = new PageReference('/' + stdCntrl.getId() + '/e'); }else{ pr = new PageReference('/' + stdCntrl.getId() ); } pr.getParameters().put('nooverride', '1'); } // If Customer Community User }else{ if( this.isNew != null && this.isNew ){ pr = Page.CCMTY_CaseEdit; }else{ if( [select RecordType.Name from Case where Id = :stdCntrl.getId()].RecordType.Name == 'Warranty' ){ pr = Page.CCMTY_WarrantyEdit; }else{ if( this.isEdit != null && this.isEdit ){ pr = Page.CCMTY_CaseEdit; }else{ pr = Page.CCMTY_CaseView; } } } 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; } }
Please refer to one of the popular blogs from Jeff Douglas for the similar kind of issue.
http://blog.jeffdouglas.com/2008/11/14/redirecting-users-to-different-visualforce-pages/
https://developer.salesforce.com/forums/?id=906F000000096HtIAI
I hope this information has been helpful in resolving your issue. Please be sure to mark a post that has been most helpful as “Best Answer” to help others in the community with similar questions.
Best Regards,
Nagendra.P