• ScottB
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hi, this code is functional but I think that it needs to be bulkified and improved. Can anyone provide a rewrite using best practices please? Thanks in advance!
 
trigger Results on Results__c (before insert, before update) {
    
    for (Results__c res : Trigger.new) {
        if (res.Name == '4'){
            
            List<Game__c> game = [SELECT Fourth_Place_Award__c
                                 FROM Game__c WHERE Id = :res.Game__c];
            	
            for(Game__c g : game){
                            If (g.Fourth_Place_Award__c == 0)
                            			{
                						res.Bubble__c = TRUE;
            							}
            						}

            				}
            
        }
        
    }

 
  • January 18, 2017
  • Like
  • 0
Hi, this code is functional but I think that it needs to be bulkified and improved. Can anyone provide a rewrite using best practices please? Thanks in advance!
 
trigger Results on Results__c (before insert, before update) {
    
    for (Results__c res : Trigger.new) {
        if (res.Name == '4'){
            
            List<Game__c> game = [SELECT Fourth_Place_Award__c
                                 FROM Game__c WHERE Id = :res.Game__c];
            	
            for(Game__c g : game){
                            If (g.Fourth_Place_Award__c == 0)
                            			{
                						res.Bubble__c = TRUE;
            							}
            						}

            				}
            
        }
        
    }

 
  • January 18, 2017
  • Like
  • 0