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
Shawn Reichner 29Shawn Reichner 29 

SOQL 101 Error on Trigger

Hello Awesome Devs,

I have the followign Trigger that has ben working without error, but now that I have an need to update all of our Account records in our Org, I am hitting SOQL 101 errors a plenty.  Anyone have any thoughts on how to bulkify this code even more to stop these errors? 

Thank you for any help you are able to provide.....


Trigger code - 
trigger SetAccountActiveOnContactRecord on Account (after insert, after update) {

    List<Contact> consToUpdate = new List<Contact>();
    set<id> accIds = new set<id>();
    For(Account a :{
        If(a.Status__c == 'Active'){
   List<Contact> consToAdd = [SELECT ID, Account_Active__c, AMP_Notification_Types__c, Contact_Types__c FROM Contact WHERE AccountId = : accIds  AND Account_Active__c != True AND 
                                       (AMP_Notification_Types__c INCLUDES('Technical','Billing','Account') OR Contact_Types__c INCLUDES('Technical'))];
            For(Contact c : consToAdd){
                c.Account_Active__c = True;
        update consToUpdate;


Change this AccountId = : accIds 
AccountId IN : accIds 
Shawn Reichner 29Shawn Reichner 29
I made the change, but am still receiving the SOQL 101 errors on this trigger.  Thanks for the thought, any other ideas from anyone to help resolve this issue? 
How many records are you trying to update ?
Shawn Reichner 29Shawn Reichner 29
10k plus.  So my trigger is bulkified?  I thought it was, but am struggling to identify why?