Created
May 12, 2018 19:38
-
-
Save sfmishra/1b08ea0f78ff7b4beb5574f38b0201e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AccountRedirectionController { | |
public string accId; | |
public string recName; | |
public AccountRedirectionController(ApexPages.StandardController stdcontroller) { | |
if(ApexPages.currentPage().getparameters().get('id')!=null) { | |
accId = ApexPages.currentPage().getparameters().get('id'); | |
recName = [SELECT Id, RecordtypeId, RecordType.name FROM Account where Id =: accId ].RecordType.Name; | |
} | |
} | |
public pageReference redirectToStandardpage() { | |
Schema.DescribeSObjectResult accResult = Account.SObjectType.getDescribe(); | |
Map<String,Schema.RecordTypeInfo> recTypeMap = accResult.getRecordTypeInfosByName(); | |
if(recTypeMap.containsKey(recName) && recName != 'Partner') { | |
pageReference pg = new pageReference('/'+ accId); | |
pg.getParameters().put('nooverride', '0'); | |
pg.setRedirect(true); | |
return pg; | |
} | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment