Last active
April 9, 2020 20:59
-
-
Save JimBTek/eef8b2deabb3bf4cb483ea75f6448f6c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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