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
ylandraylandra 

data loader

Can anyone explain to me how the data loader works with triggers in this scenario:  I have 72 records (not a lot IMHO) and my trigger is designed to handle batch records (I don't query records inside any for loop or update any records inside a for loop)  I can post the trigger for validation if needed.  When I try to dataload these 72 records I run into the Too Many SOQL queries: 101 error on all records.  If I change the batch size down to the exact number of records, then it works without a problem.  Does anyone have any idea why this would be?  I'm just trying to figure out if there's something I could do in my code to prevent these errors without having to change the batch size.
PratikPratik (Salesforce Developers) 
Hi ylandra,

Will you please post your trigger code so we can check if it can handle bulk records.

Thanks,
Pratik
ylandraylandra
Here is the trigger:
  
trigger QM_AlignQuoteOwnerOnOpptyOwnerChange on Opportunity (after update) {
    Map<Id, Id> updatedOpptyOwners = new Map<Id, Id>();
    Set<Id> opptyIds = new Set<Id>();
    
    for (Opportunity oppty : Trigger.new){
		
		if (oppty.Do_Not_Run_Trigger_Test__c == true)
		{
			return;
		}
		
        if (oppty.OwnerId != Trigger.oldMap.get(oppty.Id).OwnerId && (oppty.Account_Super_Region__c == 'NA' || oppty.Account_Super_Region__c == 'ICON')){
            updatedOpptyOwners.put(oppty.Id, oppty.OwnerId);
            opptyIds.add(oppty.Id);
        }
    }
    
    if (opptyIds.size() > 0){
        // get all quotes that are not fulfilled for these oppties
        List<Quote__c> quotes = [select Id, OwnerId, OpportunityId__c from Quote__c where Status__c != '10 - FULFILLED' and OpportunityId__c =: opptyIds];
        if (quotes.size() > 0){
            for (Quote__c q : quotes){
                q.OwnerId = updatedOpptyOwners.get(q.OpportunityId__c);
            }
            update quotes;
        }
    }
}