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

Too many SOQL queries : 101
Can any one help with this - where am i going wrong?
trigger AutoCreateSA on Opportunity (after insert , before update,after update) { List<Service_Agreement__c> listSA = new List<Service_Agreement__c>(); List<Commission_Tracking__c> listCOM = new List<Commission_Tracking__c>(); for(Opportunity o : trigger.new) { if(Trigger.isUpdate) { if(o.StageName == 'Closed Won' && o.SA_Generated__c == FALSE) { listSA.add(new Service_Agreement__c( name = o.Name + ' - ' + o.Service_Type2__c, Related_Account__c = o.accountid, Related_Opportunity__c = o.id, BD_Owner__c=o.OwnerId, DEBUG_BDApprovalREQ__c=o.Sales_Script_Approval_Req__c, Primary_Contact__c = o.Primary_Opportunity_Contact__c)); listCOM.add(new Commission_Tracking__c( Opportunity__c = o.Id)); } } if(Trigger.isInsert) { if(o.StageName == 'Closed Won' && o.SA_Generated__c == FALSE) { listSA.add(new Service_Agreement__c( name = o.Name + ' - ' + o.Service_Type2__c, Related_Account__c = o.accountid, Related_Opportunity__c = o.id, BD_Owner__c=o.OwnerId, DEBUG_BDApprovalREQ__c=o.Sales_Script_Approval_Req__c, Primary_Contact__c = o.Primary_Opportunity_Contact__c)); listCOM.add(new Commission_Tracking__c( Opportunity__c = o.Id)); } } if(listSA.size() > 0) { o.SA_Generated__c = TRUE; } if(listSA.size() > 0) { insert listSA; } if(listCOM.size() > 0) { insert listCOM; } } }
Hi,
Could you please check if any other trigger is there on "Service_Agreement__c" or "Commission_Tracking__c"?
Looks like triggers are calling each other in recursion.