function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RstrunkRstrunk 

Trigger and SOQL limits issue

 

 

I am trying to write a trigger and keep getting errors for too many soql queries.  Rather than post the code I decided to just list my requirements and see if anyone has some suggestions.  

 

First, a little background info:

 

1. The object is CASE

2. Custom lookup field on Case named Parent__c

     That field is a lookup to the case object.  (Will link multiple cases to one case).

3. Custom NUMBER field on Case named Iteration__c

     This field is meant to hold the number of cases that are related to it.  

 

 

The requirements:

 

For every case that is updated or inserted and has a value in Parent__c

I need the trigger to find all cases that have the same value in that field and update the the 

Iteration__c field with the number of total cases with that same value in Parent__c.  

The parent record will also need its iteration__c field updated with the same number.

 

 

The logic seems pretty straight forward, but when I try to Bulkify the trigger, I keep running into limit 

issues.  

 

Any suggestions would be greatly appreciated.

 

Tim BarsottiTim Barsotti

Please post your code.

 

I also recommend you review this: http://wiki.developerforce.com/page/Best_Practice%3A_Bulkify_Your_Code

nickwick76nickwick76

Hi, 

Which limits issues do you run into, SOQL?

I agree that it will be much easier to help with some code to look at.

 

// Niklas

souvik9086souvik9086

Please post your code. To solve the TOO many SOQL Query we need to know the way you went forward to it and then we can give ideas for the workaround.

 

Thanks