Created
November 7, 2012 09:45
-
-
Save cdeckert/4030447 to your computer and use it in GitHub Desktop.
Auto Populate fields while creating a new record in Salesforce
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 SObjectFillNameController | |
{ | |
ApexPages.StandardController stdController; | |
public SObjectFillNameController(ApexPages.StandardController controller) { | |
stdController = controller; | |
stdController.getRecord(); | |
} | |
public PageReference redirect() | |
{ | |
PageReference redirectPR = new PageReference('/'+TriggerUtils.sObjectKeyPrefix.get(String.valueOf(stdController.getRecord().getSObjectType()))+'/e?'); | |
redirectPR.getParameters().putAll(ApexPages.currentPage().getParameters()); | |
redirectPR.getParameters().put('nooverride', '1'); | |
if(redirectPR.getParameters().containsKey('noNameValue') && redirectPR.getParameters().get('noNameValue')=='1') | |
{ | |
redirectPR.getParameters().remove('noNameValue'); | |
} | |
else | |
{ | |
redirectPR.getParameters().put('Name', '– wird generiert –'); | |
} | |
if(redirectPR.getParameters().containsKey('customRecordType')) | |
{ | |
redirectPR.getParameters().put('RecordType', TriggerUtils.recordTypes.get(redirectPR.getParameters().get('customRecordType'))); | |
} | |
redirectPR.getParameters().remove('save_new'); | |
return redirectPR; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment