Skip to content

Instantly share code, notes, and snippets.

@cdeckert
Created September 20, 2014 07:39
Show Gist options
  • Save cdeckert/ac99ab8afc882ea759be to your computer and use it in GitHub Desktop.
Save cdeckert/ac99ab8afc882ea759be to your computer and use it in GitHub Desktop.
public void massUpdate() {
// first loop (don't forget to use Lists
for (List < Contact > contacts: [SELECT FirstName, LastName FROM Contact]) {
for (Contact c: contacts) { // 2nd for loop
if (c.FirstName == 'Barbara' &&
c.LastName == 'Gordon') {
c.LastName = 'Wayne';
}
}
update contacts; // update is part of the 1st for loop
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment