You need to sign in to do that
Don't have an account?
Shawn 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.....
Shawn
Trigger code -
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.....
Shawn
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 : Trigger.new){ If(a.Status__c == 'Active'){ accIds.add(a.id); } } 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'))]; If(consToAdd.size()>0){ For(Contact c : consToAdd){ c.Account_Active__c = True; consToUpdate.add(c); } } if(consToUpdate.size()>0){ update consToUpdate; } }
Change this AccountId = : accIds
to
AccountId IN : accIds