+ Start a Discussion
RudiHulsbosRudiHulsbos 

Eclipse deployment failing with Maximum trigger depth exceeded

Hi There,

 

We have a class and 2 triggers to deploy to production, everything works perfectly in the sandbox, but when we deploy toproduction we get the following errors:

 

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY - Maximum trigger depth exceeded on a non recursive trigger

 

We have 2 triggers on the Quotes object and it seems these triggers are causing the issue, but im not sure how to fix them, i have added the code for the triggers below.

 

If anybody could assist woth this it would be great!!

 

trigger UpdateAdjustedFieldsLineItems on SFDC_520_Quote__c (after update) {

  //Get Quote ID
  SFDC_520_Quote__c[] q1 = trigger.new;
  String strQID = q1[0].id;
  System.debug('E Quote Id : '+strQID);

  //Get QuoteLine ID's and Adjusted Fields
  SFDC_520_QuoteLine__c[] ql1 = [SELECT Adjusted_COST_PRICE__c,
                                Adjusted_SELLING_PRICE__c
                                FROM SFDC_520_QuoteLine__c WHERE Quote__r.Id = :strQID];
                               
  System.debug('E Size ql1 : '+ ql1.size());
 
  for (Integer i = 0; i < ql1.size(); i++) {                             
                               
   String strQLID = ql1[i].id;
   System.debug('E Quote Line Id : '+strQLID);

   Decimal strAdjCost = ql1[i].Adjusted_COST_PRICE__c;
   Decimal strAdjSell = ql1[i].Adjusted_SELLING_PRICE__c;
 
   System.debug('E ADJ COST : '+strAdjCost);
   System.debug('E ADJ SELLING : '+strAdjSell);
 
   //Update Adjusted Fields
   if((strAdjCost != 0.0) && (strAdjSell != 0.0)) {

     SFDC_520_QuoteLine__c[] q = [SELECT Adjusted_GP_Perc__c FROM SFDC_520_QuoteLine__c WHERE Id = :strQLID];
     Decimal strAdjGP = 1 - (strAdjCost / strAdjSell) * 100;
     System.debug('E Adjusted GP Perc : ' + strAdjGP);                           
     q[0].Adjusted_GP_Perc__c = strAdjGP; 

     update q;
    }
  }
}

Message Edited by RudiHulsbos on 05-28-2009 09:15 AM
RudiHulsbosRudiHulsbos

Second trigger extract:

 

trigger CalculateSectionTotals on SFDC_520_Quote__c (after update) {

 
 
  String strQID;
  String strQLID;
  String strQLSec;

 //Get Quote ID
  SFDC_520_Quote__c[] q1 = trigger.new;
  strQID = q1[0].id;
  System.debug('E Quote Id : '+strQID);

  //Get QuoteLine IDs, Sections and Amounts
  SFDC_520_QuoteLine__c[] ql1 = [SELECT Id, Section__c, Qty_Ordered__c, Ext_Net_Price__c, Installation_Price__c
                                     ,X1_Year_Price__c, X2_Year_Price__c, X3_Year_Price__c
                                     FROM SFDC_520_QuoteLine__c WHERE Quote__r.Id = :strQID
                                     order by Section__c];
                               
  System.debug('E Size ql1 : '+ ql1.size());
                               
  //Do Calculations
  for (Integer i = 0; i < ql1.size(); i++) {                             
                               
   strQLID = ql1[i].id;
   strQLSec =  ql1[i].Section__c;
   System.debug('E Quote Line Id (Section) : '+strQLID +'('+strQLSec +')');
  
   if(strQLSec=='1') {
    Section1AmountTotal += ql1[i].Ext_Net_Price__c;
    Section1QtyTotal += ql1[i].Qty_Ordered__c;
    Section1InstallationTotal += ql1[i].Installation_Price__c;
    Section1MaintYear1Total += ql1[i].X1_Year_Price__c;
    Section1MaintYear2Total += ql1[i].X2_Year_Price__c;
    Section1MaintYear3Total += ql1[i].X3_Year_Price__c;
   }
  
  
 

 //check if exist
 Quote_Section_Totals_HO__c[] q = [SELECT Section_1_Amount_Total__c, Section_1_Qty_Total__c,
         Section_10_Maint_Year_3_Total__c FROM
         Quote_Section_Totals_HO__c WHERE Quote__r.Id = :strQID];

 if(q.size()>0) {
 //Update Total Fields
                            
         q[0].Section_1_Amount_Total__c =  Section1AmountTotal;
         q[0].Section_1_Qty_Total__c = Section1QtyTotal;
         q[0].Section_1_Installation_Total__c = Section1InstallationTotal;
 
      
       update q;
   }
   else
   {
     //Insert Total Fields
     Quote_Section_Totals_HO__c newQST = new Quote_Section_Totals_HO__c(
         Quote__c = strQID,
         Section_1_Amount_Total__c =  Section1AmountTotal,
         Section_1_Qty_Total__c = Section1QtyTotal,
         Section_1_Installation_Total__c = Section1InstallationTotal,

         ); 
               
         insert newQST;
   }   

}