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
Abhishek Pal 33Abhishek Pal 33 

Does validation rules or workflow counts for SOQL queries(100) governor limits?

Hello Everyone,

In one of the apex class I am hitting the SOQL queries governor limit. But I have not written any SOQL statements in it.
For the below code I am getting  Number of Queries used in this Apex code so far in updateStoreStatus: 100.

Code:-

 List<Account> updateAccounts = new List<Account>();
        List<Id> updateAccountIds = new List<Id>();
        // Check if the TD Status changed from closed to open or pending to open        for(Account newAccount : newAccounts.values()) {
            if( (newAccount.TD_Status__c == 'Open') && 
                (oldAccounts.get(newAccount.id).store_Status__c == 'Closed' || oldAccounts.get(newAccount.id).store_Status__c == 'Pending' )) {
                    updateAccountIds.add(newAccount.id);
            }
        }
        System.debug(LoggingLevel.INFO,'UpdateStoreList Size' + updateAccountIds.size());

Can someone please help how this code giving me 100 SOQL execution.?

NOTE:- If I check logs I can see lots of workflow and validation rules are executing.

Thanks in advance.

-Abhishek
Amit Chaudhary 8Amit Chaudhary 8
It look like your code become recursive some where that is why this issue is coming
Abhishek Pal 33Abhishek Pal 33
HI Amit,

But I am not seeing any such condition where the code becomes recursive.
One more things when I check logs I see lots of validation rules/workflows executed before  this method. Does this leads to increasing the SOQL governor limits. If yes Can you please help how to overcome this error. 

-Abhishek