You need to sign in to do that
Don't have an account?
How do I iterate over the child objects without using SELECT query
Hi,
I have the contact object. Work Allocation is a custom child object of Contact.
How do I iterate over these child records without using SELECT query inside the FOR loop.
My Trigger handler code is here. Although it's working fine, I know it's not bulkified. Please help:
public static void checkWorkAlloc(List<Work_Allocation__c> workAllocList){
for (Work_Allocation__c wk : workAllocList){
//Collect the work allocation records under the parent Contact in an array
Work_Allocation__c[] wkAlList=[SELECT Id, Start_Date__c, End_Date__c FROM Work_Allocation__c WHERE Contact_Resource__c =: wk.Contact_Resource__c];
if(wkAlList.size()>0){
for (Integer i=0; i < wkAlList.size(); i++){
Work_Allocation__c workAlloc1=wkAlList[i];
please try below code
If you find your Solution then mark this as the best answer.
Thank you!
Regards,
Suraj Tripathi