Skip to content

Instantly share code, notes, and snippets.

@victorabraham
Last active August 29, 2015 14:19
Show Gist options
  • Save victorabraham/8a75bd1227ab5b16e4a0 to your computer and use it in GitHub Desktop.
Save victorabraham/8a75bd1227ab5b16e4a0 to your computer and use it in GitHub Desktop.
Code that is not bulkified and contains query inside for loop
//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