Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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