You need to sign in to do that
Don't have an account?

System.LimitException: Too many SOQL queries: 101
Hi All,
I'm getting the following error: System.LimitException: Too many SOQL queries: 101. I didn't think my query was inside a loop so I'm unsure how to fix the problem. Your help is greatly appreciated!
trigger setContactAndAccountIdOnOrder on Lead (after update) { Map<String,Id> Ids = new Map<String,Id>(); for(Lead lead : Trigger.new) { if (lead.IsConverted) { Ids.put(lead.Person_Id__c,lead.Id); } } List<Order__c> orders = [select Id, Person_Id__c, Contact__c, Account__c from Order__c WHERE Person_Id__c IN :Ids.keySet()]; for (Order__c o : orders) { Id personId = Ids.get(o.Person_Id__c); Lead ld = trigger.newMap.get(personId); o.Contact__c = ld.ConvertedContactId; o.Account__c = ld.ConvertedAccountId; } update orders; }
Do you have other triggers that are beng fired from this trigger? Per haps a update order trigger? And maybe that/those triggers are causing the query limit to be hit?
There is an after update trigger on the Order__c object. It does contain one query that is within a for loop....so, it looks like this is the problem. I need the ports map to be defined outside the if statement because I reference the size of ports later. Any suggestions on how to rework this code is appreciated!
2. You have trigger Order__c
3. Triggers are firing recursively.
4. You have workflow field update, which is causing triggers to execute again.