function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jannie TheunissenJannie Theunissen 

Record not created as debug log reports

In my sandbox I am debugging a Web-to-Lead issue that has to do with the custom Lead trigger code. I have a trigger handler that gets called after lead insert. The handler does a few things like creating a new Account and Case record. When I run my lead test class all the tests pass and the records are created as expected. However when I do a test web-to-lead post, no errors are reported in the browser or in the debug log, but the records are not created. Some excerpts from the debug log that indicate that the records were created are:

    08:14:52.189 (189585256)|METHOD_ENTRY|[36]|01p18000000DBJy|LeadTriggerHandler.postProcessInsert(Lead)
    08:14:52.189 (189684839)|SYSTEM_METHOD_ENTRY|[41]|String.valueOf(Object)
    08:14:52.189 (189735694)|SYSTEM_METHOD_EXIT|[41]|String.valueOf(Object)
    08:14:52.189 (189773735)|SYSTEM_METHOD_ENTRY|[41]|System.debug(ANY)
    08:14:52.189 (189787753)|USER_DEBUG|[41]|DEBUG|##*** New lead: 00Q18000001RfrzEAC
    08:14:52.189 (189797840)|SYSTEM_METHOD_EXIT|[41]|System.debug(ANY)
    08:14:52.189 (189924877)|SYSTEM_METHOD_ENTRY|[46]|System.debug(ANY)
    08:14:52.189 (189952704)|USER_DEBUG|[46]|DEBUG|##*** lead status is open and Email is: jj@example.com 

The problem goes away if I uninstall the Salesforce for Social Media app. I can only assume there is some conflict between the managed app and my own custom lead trigger code, but how can I debug the conflict if the debug log report is not reliable?
KRayKRay
Hey Jannie, reach out to SF Support. They should be able to point exactly what's causing the conflicts and possibly provide a solution. 
Jannie TheunissenJannie Theunissen
Thanks KRay. I'm affraid SF Support spent quite a bit of time working with me on this problem and then suggested I post here. "Developer support is currently available only to our premier customers and partners. We have dedicated support agents that work the boards to answer questions and review questions to ensure that you get a response."
KRayKRay
ok, that sucks.  Can you post the entire log?  Worst case scenario, you'll have to use the developer console, to see EVERYTHING that's occuring a lead is created. 
Jannie TheunissenJannie Theunissen
Here is the full debug log and my code trigger handler and test (https://gist.github.com/anonymous/b0fd6d3f2254de3c382b)
KRayKRay
Line#464 & 469 has errors. 
Jannie TheunissenJannie Theunissen
Sure. I can account for those error messages, they don't affect the flow of the trigger script. What troubles me is that the debug log reports the creation and existence of expected records (Account on line 199, and Case on line 999) which are not there.
KRayKRay
ON line#236, shows where the social app is starting. In your code, can you comment out the "existingContact" check and just assume that the contact and account is new.