SalesforceFoundation / NPSP

The current version of the Salesforce.org Nonprofit Success Pack
http://www.salesforce.org/nonprofit/nonprofit-success-pack/
BSD 3-Clause "New" or "Revised" License
16 stars 3 forks source link

TDTM error with the DML Wrapper #2445

Closed RBLopez closed 7 years ago

RBLopez commented 7 years ago

I'm running into an issue using the TDTM structure when trying to use the DMLWrapper class to insert objects.

I've successfully run through my logic and generated a list of additional objects that I would like inserted. I used the example code here (http://developer.salesforce.org/#blog/post/2016/06/10/table-driven-trigger-management.html) as my guide on how to add my records to the DML wrapper, and have confirmed in my test code that I'm adding 12 rows to objectsToInsert list in the wrapper. However, there is only 1 record being inserted by the TDTM code.

My guess is that somehow the groupSObjects method is causing this behavior? See the screenshot of my error log here (I also have the full logs if you want them). Should I be adding items to the wrapper in some other way to make sure that this doesn't happen?

2017-01-10 17_14_57-cs3 _ force com developer console

davidhabib commented 7 years ago

are you sure you are adding 12 unique objects to DML Wrapper? the first thing that groupSObjects() does is remove duplicate objects. Other than that, I doubt that groupSObjects() is doing the wrong thing, since we use it internally, and it is all generic (ie, not npsp or standard object specific). You could copy the code of groupSObjects() to your org and run it yourself with your data to prove whether it is at fault. code is here: https://github.com/SalesforceFoundation/Cumulus/blob/dev/src/classes/TDTM_Runnable.cls#L149

judisohn commented 7 years ago

Hi @RBLopez in the future, feel free to post this to the NPSP Group in the Hub and we can troubleshoot it with you there. Thanks!