Created
February 8, 2012 21:16
-
-
Save joshbirk/1773947 to your computer and use it in GitHub Desktop.
Simple Wizard Example
This file contains hidden or 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 WizardExample { | |
| public Contact c {get; set;} | |
| public WizardExample(ApexPages.StandardController controller) { | |
| //reference the contact from the standardcontroller | |
| c = (Contact)controller.getRecord(); | |
| } | |
| public PageReference Step1() { | |
| //forcing a recordtype | |
| RecordType r = [SELECT Id from RecordType WHERE Name = 'TestData' ]; | |
| c.RecordTypeId = r.Id; | |
| return Page.StepOne; | |
| } | |
| public PageReference Step2() { | |
| //detecting a recordtype | |
| List<RecordType> r = [SELECT Name from RecordType WHERE ID =: c.RecordTypeId ]; | |
| if(r.size() > 0) { | |
| if(c.Phone == null && r[0].Name == 'TestData') { c.Phone = '800-888-8888'; } | |
| } | |
| return Page.StepTwo; | |
| } | |
| public PageReference saveContact() { | |
| //save data | |
| upsert c; | |
| return null; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment