You need to sign in to do that
Don't have an account?
Steven Wellman 28
Need help with bulkification
Not sure how to bulkify this trigger:
trigger OppPaymentCollected on Account (after update) { List<Opportunity> oppsToUpdate = new List<Opportunity>(); for (Account acc : Trigger.new) { // Get trigger.old and trigger.new versions of the record Account oldAcc = Trigger.oldMap.get(acc.Id); Account newAcc = Trigger.newMap.get(acc.Id); // Create variable to store value to see if payment date has changed. Boolean newPayment = oldAcc.Most_Recent_Payment__c != newAcc.Most_Recent_Payment__c; // Query and find all Oppos that are 'Sold' if(newPayment) { List<Opportunity> opps = [SELECT Id, Date_Customer_Paid__c FROM Opportunity WHERE StageName = 'Sold' AND Date_Customer_Paid__c = null AND AccountId = :acc.Id]; for (Opportunity oppty : opps) { oppty.Date_Customer_Paid__c = Date.Today(); oppsToUpdate.add(oppty); } } } update oppsToUpdate; }Any help appreciated.
Best Answer chosen by Steven Wellman 28
Raj Vakati
Use this code