• Sudhir.k
  • 25 Points
  • Member since 2016

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 4
Hi All,

I'm attmepting to create a trigger on a custom object, which is a child of the opportunity. The triggers intention, is to check the oppotunity's Opportunity Line Items, and see if the product exists then create a custom object that is a child of the custom object the trigger is being initiated at.

I get the follwoing error, Error:Apex trigger ReturnSends caused an unexpected exception, contact your administrator: ReturnSends: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ReturnSends: maximum trigger depth exceeded... I'm trying to figure out how to avoid this error, I know why I'm getting just can't figure out how to correct so it doesn't happen again.

I've put my code below for any help. Thanks

trigger ReturnSends on Change_Request__c (after insert, after update) {

List<Change_Request_Product__c> CRUpdates = new List<Change_Request_Product__c>();
Map<ID, Change_Request__c> oppList = new Map<ID, Change_Request__c>();
List<ID> CRList = new List<ID>();
Map<ID, Change_Request__c> coppList = new Map<ID, Change_Request__c>();

for (Change_Request__c cr : Trigger.new){
    if (cr.CR_State__c == 'Created'){
        if (cr.OAP_Send_POE__c != null){

if (!coppList.isEmpty()){
for (Change_Request__c cru : [select Id, P_Send__c, P_Send__c, Opportunity_Name__c from Change_Request__c where id in :coppList.keyset()]){
    Change_Request__c OppObj = coppList.get(cru.Id);
    if(OppObj != null){
    for ( OpportunityLineItem oli : [select Id, Product2.Id, Product2.Name, Quantity, UnitPrice, OpportunityID, Opportunity.CurrencyIsoCode from OpportunityLineItem where OpportunityId = :cru.Opportunity_Name__c]){
               if (oli.Product2.Name == 'P30' && cru.P_Send__c != null){
               Change_Request_Product__c crp = new Change_Request_Product__c(Change_Request__c=cru.id,Product__c=oli.Product2.Id, Quantity__c = cru.P_Send__c, Sales_Price__c = oli.UnitPrice, AP_Price__c=decimal.valueof('540'), CurrencyIsoCode = oli.Opportunity.CurrencyIsoCode);
if (!CRUpdates.isEmpty()){
insert CRUpdates;

I need help i am stuck and I am not able to continue. I am facing the below issue:

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger lastPrimaryQuote caused an unexpected exception, contact your administrator: lastPrimaryQuote: execution of BeforeInsert caused by: System.DmlException: Update failed. First exception on row 0 with id a1O6E000000Cr7ZUAS; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 3016E000000Cqdx. Flow error messages: An unhandled fault has occurred in this flow
An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Contact your administrator for help.: []: Trigger.lastPrimaryQuote: line 14, column 1

My code seems to be fine but I am wondering if i am doing the proper DML call.

Here you are my code.
trigger lastPrimaryQuote on SBQQ__Quote__c (before insert) {

    List<SBQQ__Quote__c> quotes = new List<SBQQ__Quote__c>();
    List<SBQQ__Quote__c> quotesToUpdate = new List<SBQQ__Quote__c>();

    quotes =[select Id, SBQQ__Primary__c,  CreatedDate from SBQQ__Quote__c  where SBQQ__Opportunity2__c =:'0066E000002L4T5'];
    for(SBQQ__Quote__c qu : quotes){
    update quotesToUpdate;

thanks in advance
<aura:component >
	<aura:attribute name="item" type="Camping_Item__c" required="true"/>

	<ui:outputText value="{!v.item.Name}" />
	<ui:outputCheckbox value="{!v.item.Packed__c}" />
	<ui:outputCurrency value="{!v.item.Price__c}" />
	<ui:outputNumber value="{!v.item.Quantity__c}" />
	<ui:button label="Packed!" press="{!c.packItem}"/>
	packItem : function(component, event, helper) {
		var button = event.getSource().get("v.disabled");
		component.set("v.item.Packed__c", "true");
		component.set(button, "true");
What am I doing wrong?


anyone know how to find out what edition of salesforce an org has i.e. unlimited, enterprise, professional etc..