Skip to content

Instantly share code, notes, and snippets.

@joshbirk
Created February 8, 2012 21:16
Show Gist options
  • Select an option

  • Save joshbirk/1773947 to your computer and use it in GitHub Desktop.

Select an option

Save joshbirk/1773947 to your computer and use it in GitHub Desktop.
Simple Wizard Example
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