/*
* @author: Sumitkumar Shingavi (sumi.shingavi@gmail.com)
* @created_date: 04/18/2015
* @description: This class performs all Data Manipulation methods on Account object
*/
public class AccountTriggerActions {
/*
* @auther : Sumitkumar Shingavi (sumi.shingavi@gmail.com)
* @date : 04/18/2015
* @description : This method does nothing at this moment
* @parameters : List of Accounts
* @returns : Nothing
*/
public static void myAction(List<Account> lAccounts) {
//Write logic here for myAction method
Set<Id> sAccountIds = new Set<Id>();
List<Contact> lContacts = new List<Contact>();
Map<Id, Opportunity> mOpportunities = new Map<Id, Opportunity>();
Asset assetInstance = new Asset();
Integer iCounter = 0;
Boolean bIsChecked = FALSE;
//Below is the right format to write SOQLs
List<Case> lCases = [SELECT Id, CaseNumber
FROM Case
WHERE AccountId IN :lAccounts
AND ContactId IN :lContacts
ORDER BY CaseNumber
LIMIT 10000];
//Use below format of for loops when you need to process up to 5M records as this for loop auto uses queryMore()
for(Product2 productInstance : [SELECT Id, Name FROM Product2 WHERE isActive = TRUE]) {
}
}
/*
* @auther : Sumitkumar Shingavi (sumi.shingavi@gmail.com)
* @date : 04/18/2015
* @description : This method prepares data for WS call
* @parameters : List of New Accounts, Map of New Account records, Map of Old Account Records
* @returns : Nothing
*/
public static void actionCallingWSFutureCall(List<Account> lNewAccounts, Map<Id, Account> mNewAccounts, Map<Id, Account> mOldAccounts) {
//Forming a Set: As future method can only take param as Set/List of primitive data types like Id, Integer, etc.
Set<Id> sAccountIds = new Set<Id>();
for(Account accInstance : lNewAccounts) {
sAccountIds.add(accInstance.Id);
}
//Ws Call: Calling Future method which make a WS call for some external server
makeWSCall(sAccountIds);
}
/*
* @auther : Sumitkumar Shingavi (sumi.shingavi@gmail.com)
* @date : 04/18/2015
* @description : This method makes a asynch call to some external server and get response back
* @parameters : Set of Account Ids
* @returns : Nothing [It might be a response string in practical scenarios]
*/
@future (Callout=true)
private static void makeWSCall(Set<Id> sAccountIds) {
}
}