You need to sign in to do that
Don't have an account?
AlSawtooth
Maximum Trigger Depth Exceeded
Hello,
I'm getting an error that I think is recursion-based and I'm not sure how to fix it. Basically, I'm trying to update the DD field on my DDCustom__c object with a value from my Opportunity field UpdateDD__c (which is a lookup).
I'm getting an error that I think is recursion-based and I'm not sure how to fix it. Basically, I'm trying to update the DD field on my DDCustom__c object with a value from my Opportunity field UpdateDD__c (which is a lookup).
trigger UpdateDD2 on DDCustom__c (after update, after insert) { List<DDCustom__c> des = [select Id, DD__r.Id, Opportunity__r.Id from DDCustom__c where Id in :Trigger.newMap.keySet()]; List<Opportunity> opp = [select Id, UpdateDD__c, UpdateDD__r.Id from Opportunity where Id = : des[0].cv__Opportunity__r.Id and UpdateDD__c != null]; List<DDCustom__c> des2 = new List<DDCustom__c>(); Set<DDCustom__c> desSet = new Set<DDCustom__c>(); for(DDCustom__c d : des){ if(des2.size()>0){ desSet.addAll(des2); } if((! desSet.contains(d)) && (opp[0].UpdateDD__c != null) && (d.DD__r.Id != opp[0].UpdateDD__r.Id)){ d.DD__r.Id = opp[0].UpdateDD__r.Id; des2.add(d); } } update des2; }
I'm checking to see if the list size is greater than 0 to prevent a recursive loop - when DD is modified, it will be in trigger. new again, so I wanted to make sure that I don't continuously update it.
Also, taking the field update out of the for loop doesn't help me at all...
Does that make sense?
Thanks for your help!