Last active
August 29, 2015 14:19
-
-
Save victorabraham/8a75bd1227ab5b16e4a0 to your computer and use it in GitHub Desktop.
Code that is not bulkified and contains query inside for loop
This file contains 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
//Querying all parent records | |
for(Parent__c parent: [SELECT Id,name,Status__c FROM Parent__c]) | |
{ | |
if(parent.Status__c =='Completed') | |
{ | |
//If parent status is Completed querying all child records. | |
List<child__c> childList = [SELECT Id,Name,Parent__c, child_Status__c FROM Child__c WHERE Parent__c=:parent.id]; | |
for(child__c child:childList) | |
{ | |
//Changing child status as completed and updating record. | |
child.child_status__c ='Completed'; | |
update child; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment