document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /*
  2. * @author: Sumitkumar Shingavi (sumi.shingavi@gmail.com)
  3. * @created_date: 04/18/2015
  4. * @description: This class performs all Data Manipulation methods on Account object
  5. */
  6. public class AccountTriggerActions {
  7.  
  8. /*
  9. * @auther : Sumitkumar Shingavi (sumi.shingavi@gmail.com)
  10. * @date : 04/18/2015
  11. * @description : This method does nothing at this moment
  12. * @parameters : List of Accounts
  13. * @returns : Nothing
  14. */
  15. public static void myAction(List<Account> lAccounts) {
  16. //Write logic here for myAction method
  17.  
  18. Set<Id> sAccountIds = new Set<Id>();
  19. List<Contact> lContacts = new List<Contact>();
  20. Map<Id, Opportunity> mOpportunities = new Map<Id, Opportunity>();
  21. Asset assetInstance = new Asset();
  22. Integer iCounter = 0;
  23. Boolean bIsChecked = FALSE;
  24.  
  25. //Below is the right format to write SOQLs
  26. List<Case> lCases = [SELECT Id, CaseNumber
  27. FROM Case
  28. WHERE AccountId IN :lAccounts
  29. AND ContactId IN :lContacts
  30. ORDER BY CaseNumber
  31. LIMIT 10000];
  32.  
  33. //Use below format of for loops when you need to process up to 5M records as this for loop auto uses queryMore()
  34. for(Product2 productInstance : [SELECT Id, Name FROM Product2 WHERE isActive = TRUE]) {
  35.  
  36. }
  37. }
  38.  
  39. /*
  40. * @auther : Sumitkumar Shingavi (sumi.shingavi@gmail.com)
  41. * @date : 04/18/2015
  42. * @description : This method prepares data for WS call
  43. * @parameters : List of New Accounts, Map of New Account records, Map of Old Account Records
  44. * @returns : Nothing
  45. */
  46. public static void actionCallingWSFutureCall(List<Account> lNewAccounts, Map<Id, Account> mNewAccounts, Map<Id, Account> mOldAccounts) {
  47.  
  48. //Forming a Set: As future method can only take param as Set/List of primitive data types like Id, Integer, etc.
  49. Set<Id> sAccountIds = new Set<Id>();
  50. for(Account accInstance : lNewAccounts) {
  51. sAccountIds.add(accInstance.Id);
  52. }
  53. //Ws Call: Calling Future method which make a WS call for some external server
  54. makeWSCall(sAccountIds);
  55. }
  56.  
  57. /*
  58. * @auther : Sumitkumar Shingavi (sumi.shingavi@gmail.com)
  59. * @date : 04/18/2015
  60. * @description : This method makes a asynch call to some external server and get response back
  61. * @parameters : Set of Account Ids
  62. * @returns : Nothing [It might be a response string in practical scenarios]
  63. */
  64. @future (Callout=true)
  65. private static void makeWSCall(Set<Id> sAccountIds) {
  66.  
  67. }
  68. }
');