You need to sign in to do that
Don't have an account?
rameshvpsg
SQL Error
I am using below trigger part of before update trigger on parent object to roll up amount from child object. This works fine for few records, but throws out too many soql queries error.
Please guide me how i can bulkify this trigger.
Note: revenue_schedule__c is the parent object and training_sechedule__c is the child object.
for (revenue_schedule__c revenueschvar : trigger.new)
{
AggregateResult[] groupedResults = [SELECT SUM(amount__c)amt FROM training_schedule__c WHERE Revenue_Schedule__c = :revenueschvar.id];
revenueschvar.FTE_Revenue__c =(decimal)groupedResults[0].
get('amt');
}
}
Hi
remove the SOQl inside for loop and write out side for by using IN Operator.
If you are not able to write please let me know i can help you out.
Hi Mahi,
Yes please. I am not from coding background, please help me on this.
Thanks
Ok no problem,
try this code
List<id> rsList=new List<id>();
for (revenue_schedule__c revenueschvar : trigger.new)
{
rsList.add(revenueschvar.id);
}
Hi Mahi,
Thanks for your help. I used the below code provided by another member and it worked.
Thanks again.