+ Start a Discussion
Rst123Rst123 

Too many SOQL queries: 101

I'm facing  issue :- Need help in fixing it.

Highlighted the line i'm getting Too many SOQL queries: 101

if(trigger.isAfter){       
         if(caids.size()>0){
           
                          Set<Id> RelCreditApprovalId= new Set<Id>();
              for(credit_approval__c ca:trigger.new){
               if(caids.contains(ca.id)){
                            
                  if(ca.Credit_Line_Id__c!=null){
                    system.debug('Credit Line Id (LOC): '+ca.Credit_Line_Id__c);
                    RelCreditApprovalId.add(ca.Credit_Line_Id__c);
              
                }
              }
             }
            
               List<Credit_Approval__c> RelCreditApprovalList= [select Id,Application_Type__c,Credit_Line_ID__c,Submittal_Status__c,Approved_Amount__c,Approved_Amount_With_Tolerance__c,LOC_Adjustment_Amount__c, Risk_Decision__c,Amount_Approved_Remaining__c,
                                    Credit_Line_ID__r.Submittal_Status__c,Credit_Line_ID__r.Approved_Amount__c,Credit_Line_ID__r.Approved_Amount_With_Tolerance__c,Credit_Line_ID__r.Risk_Decision__c,Opportunity__c
                                    from Credit_Approval__c where Id in :RelCreditApprovalId];

            
            
                   
             if(RelCreditApprovalList!=null && RelCreditApprovalList.size()>0){
              try{
                    update RelCreditApprovalList;
                 }catch(DMLException e){
                    system.debug('/nDML Exception : '+e.getmessage());
                 }
             }
        }     
     }
sfdc_ninjasfdc_ninja
The trigger itself should not be hitting that limit on it's own.  It looks like this could be a recursive trigger issue wither with this trigger or another trigger using DML that calls this trigger.  

Set up a debug log and try to see how many times this trigger is being called with a single DML statement triggering it. 
Elie.RodrigueElie.Rodrigue
Your problem might not be in that exact line, its mostly that in your complete execution flow you are doing too much SOQL and this one happens the be number 101  but it might not be the problematic one. If you could provided us with a debug log we could have a deeper look.