Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Controller supporting the TransactionRecordTypeDemo page that demonstrates
- * how to allow a user to select a Transaction record type from a dynamically
- * generated list.
- *
- * @version 0.3
- * @see https://developer.salesforce.com/forums/ForumsMain?id=906F00000009F1M
- * @author Marty Chang (Slalom Consulting)
- */
- public class TransactionSiteController {
- /*
- * A Transaction record template to facilitate Salesforce-native user input.
- */
- public Transaction__c proxy { get; set; }
- /*
- * Default constructor that initializes member variables
- */
- public TransactionSiteController() {
- proxy = new Transaction__c();
- }
- /*
- * @return The custom edit page for Transactions, with the specified
- * record type ID
- */
- public PageReference editWithRecordType() {
- // Define some parameters for the edit page.
- // There must be a better way to do this, because hardcoding the
- // relative URL means it's not robust and will not work in
- // Communities.
- String transactionObjectPrefix =
- Schema.SObjectType.Transaction__c.getKeyPrefix();
- PageReference nextPage =
- new PageReference('/' + transactionObjectPrefix + '/e');
- // Add parameters to pre-populate known values for the new record
- nextPage.getParameters().put('RecordType', proxy.RecordTypeId);
- String transactionAccountFieldName =
- 'CF00N90000006CdMG';
- // Hardcoding is bad. There must be a better way!
- String accountName = 'sForce'; // Hardcoded for demo purposes
- nextPage.getParameters().put(transactionAccountFieldName, accountName);
- return nextPage;
- }
- } // public class TransactionSiteController
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement