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
Dhanraj S NikamDhanraj S Nikam 

Too many SOQL Error

Hi All,

Need your help on one of the following.

I have managed Package which have Custom Quote and Custom Quote Lines.
Updating/inserting/deleting  anything on the quote line which fires Update on Quote.
All this is in Managed Package where we cannot  change any code.
Now I have requirement update anything on quote/quote line should sync with Opportunity.
So, I have written a after update trigger Quote and call SyncOppty class to Sync values to the Opportunity.
Now, If I am doing only one action on quote lines, Update Or Delete Or Insert Quote Update fires only once and everything working fine.
Note That VF page for Quote Line have ability to do Update/Delete Or Insert actions in single transaction.
Now the Issue is
If I am doing all the three actions Update ,Delete and Insert on quote line in one transaction then Quote Update fires three times and SyncOppty process as well.
               Since SyncOppty is calling three times in one truncation it gives Too Many SOQl Error.
               If I am restricting SyncOppty to not to execute multiple time in one transaction then I am not able to track any two of the actions on the quote Line which give wrong result.
               I need all the updated data after all the three actions to sync with Oppty.
One more thing I don’t want to go with “Future” Method.

Pleases help me on this above scenario ASAP if you can.
Dhanraj Nikam
PratikPratik (Salesforce Developers) 
Hi Dhanraj,

IT seems to be the SOQL statement is inside For loop. Retrieve all the records outside the Loop in a list/set.  The error of too many SOQL causes if you have used SOQL in a loop which is hitting governor limits.

Hope this will help.

Dhanraj S NikamDhanraj S Nikam
Yes Pratick,
I have SOQL outside of the loop but the whole logic whic is in SyncOppty called three times in above scenario that cause SOQL error.

i need SyncOppty  to called once after all the three actions insted of Three times.
i need updaetd data by all of the three actions on Quote Lines.