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
VisionaryVisionary 

Help bulkify this statement

i populate accTemp which is a Set<Account> with accounts that meet a certain criteria

then....
 
trigger CaseTrigger on Case (after insert, after update)
{
Set<Account> accTemp=new Set<Account>();
List<Account> accTemp2 = new List<Account>();
// code to populate accTemp set with Accounts........


 for(Account a : accTemp){
            cases = [select id, accountid from Case WHERE accountid=:a.id AND isclosed!=true and createdDate >: System.Today()-365 LIMIT 90];
            a.Nuber_Of_Open_Cases__c = cases.size();
            accTemp2.add(a);
        }
        update(accTemp2);

}

please help as i'm getting too many SOQL queries error when i do bulk upload.