Skip to content

Instantly share code, notes, and snippets.

@JimBTek
Last active April 9, 2020 20:59
Show Gist options
  • Save JimBTek/eef8b2deabb3bf4cb483ea75f6448f6c to your computer and use it in GitHub Desktop.
Save JimBTek/eef8b2deabb3bf4cb483ea75f6448f6c to your computer and use it in GitHub Desktop.
public class Account_Service{
public static void processAccounts(){
List<Account> allAccounts = [Select Id, Name, etc....]; // starting list
List<Account> accountsToUpdate = new List<Account>(); // empty list
accountsToUpdate.addAll(setOwner(allAccounts)); //return only records method1 edited
accountsToUpdate.addAll(copyAddress(allAccounts)); //return only records method2 edited
Update accountsToUpdate; //should have account records that method1, method2, or both have edited
}
public static List<Account> setOwner (List<Account> listAccounts, Boolean doDML){
List<Account> updateAccounts = new Lizt<Account>();
for (Account a : listAccounts){
if ( //some logic){
a.OwnerID = ; //something new
updateAccounts.add(a);
}
}
if(doDML){update updateAccounts;}
return updateAccounts;
}
public static List<Account> copyAddress (List<Account> listAccounts, Boolean doDML){
List<Account> updateAccounts = new List<Account>();
for (Account a : listAccounts){
if ( //some logic){
a.ShippingState = a.MailingState;
// etc.
updateAccounts.add(a);
}
}
if(doDML){update updateAccounts;}
return updateAccounts;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment