Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save AmbreJuryeaAmole/17b0915f11b72413c649f507435be524 to your computer and use it in GitHub Desktop.
Visualforce Controller - Good Example
// New account
Account a = new Account(Name = 'New Account');
insert a;
// If DML failed, salesforce shows error and rolls-back the new record
// New Case linked to account
Case c = new Case(subject = 'I need help', accountId = a.id);
insert c;
// If DML failed, salesforce shows error and rolls-back the new record
// If we get this far in code, both DML's finished properly
system.debug('Success');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment