Last active
October 8, 2015 09:38
-
-
Save karanrajs/7d231386e20d357884dc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger efficientSOQL on Invoice_Statement__c(before insert,before update) | |
{ | |
//perform SOQL query outside the for loop | |
//This query runs once for all item in the Trigger.New | |
for(Invoice_statement__c inv : [Select Id,Description__c,(select Id,Units_Sold__c from Line_Item__r) From Invoice_Statement__c where Id IN : Trigger.newMap.KeySet()]) | |
{ | |
for(Line_Item__c li:inv.LineItem__r) | |
{ | |
//do any operation | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment