• ATT.ax1917
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

Hello, I'm quite new to the bulkifying idea and need to bulkify the following sinmple trigger, which just updates a field on a parent object:

 

trigger Approval_Actions on Approval__c (after update) {
    List<Approval__c> app = trigger.new;
    Opportunity opp = [select Approval_Date__c from Opportunity where Id =: app[0].Opportunity__c LIMIT 1];
    if(app[0].Status__c == 'Approval GRANTED'){
       opp.Approval_Date__c = date.today();
    }
    update opp;
}

 

The problem is: how to bulkify it without having an SQL query in a loop?

Hello, I'm quite new to the bulkifying idea and need to bulkify the following sinmple trigger, which just updates a field on a parent object:

 

trigger Approval_Actions on Approval__c (after update) {
    List<Approval__c> app = trigger.new;
    Opportunity opp = [select Approval_Date__c from Opportunity where Id =: app[0].Opportunity__c LIMIT 1];
    if(app[0].Status__c == 'Approval GRANTED'){
       opp.Approval_Date__c = date.today();
    }
    update opp;
}

 

The problem is: how to bulkify it without having an SQL query in a loop?