Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
SQL Error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-14-2012 06:44 AM
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].
}
Re: SQL Error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-14-2012 07:07 AM
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.
Mahi
Re: SQL Error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-14-2012 07:20 AM
Hi Mahi,
Yes please. I am not from coding background, please help me on this.
Thanks
Re: SQL Error
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-14-2012 07:35 AM - edited 11-14-2012 07:51 AM
Ok no problem,
try this code
List<id> rsList=new List<id>();
for (revenue_schedule__c revenueschvar : trigger.new)
{
rsList.add(revenueschvar.id);
}
Mahi
Re: SQL Error
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-15-2012 06:08 AM
Hi Mahi,
Thanks for your help. I used the below code provided by another member and it worked.
Thanks again.

