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
MachhiMachhi 

Visualforce controller class using future method SOQL limits

Hi All,

 

I am facing problems with mass updates of records module design. I had to change my appl design in lot of way because of below scenario:

 

Scenario:

I need to update mass contact records based on filter criteria. Fields to be updated are the count of number of cases and activities against the respective contact records.

 

How it works:

I have a Visualforce page from where I call a method from the custom controller class.

 

This method queries on contact records based on filter criteria. Divide them into the quantitative batches. Collects a set of Ids for one batch and pass it to future method (asynchronous).

 

Issue:

1. Even though I am using future method, I get “Too many SOQL queries: 101” error.

I learnt that a future method allows me to work on 10,000 SOQL queries or DML statements (http://wiki.developerforce.com/index.php/Governors_in_Apex_Code).

 

Due to this, I can work only on a batch of 99 records.

Shouldn’t it be 10,000 SOQL queries which I can process in future method called through Visualforce controller?

 

2. If I activate trigger, this batch size is still decreased as execution of trigger also adds SOQL queries.

 

I don’t understand why execution of trigger adds SOQL queries to my future method limit. Even it adds to it, why it throws error after 100 SOQL queries? Also, I am also looking for an option by which I can stop trigger from being executed if I am updating records from my Visualforce controller. Having a flag field and check its value inside trigger work around is sarcastic.    

 

Please help. Salesforce looks quite intelligent to answer mass records updates requirement using future annotation but as I have experienced up to now, I can process only 700-800 records successfully not more than that which is simply not acceptable.

 

Regards,

Chandrakant M

machhi_c_m@yahoo.com

Message Edited by Machhi on 10-09-2009 12:27 AM
Message Edited by Machhi on 10-09-2009 12:28 AM
MachhiMachhi

Hi,

 

Did anybody successfully update more than 1000 records part of their mass update mission? If yes, please share your thoughts. Your help will be much appreciated.

 

Thanks in advance.

 

Regards,

Chandrakant M

Mb: +91-9987845720