0

I have a method in a trigger dispatcher that's being called in a recursive but seemingly untraceable fashion. The following log entries just repeat over and over until I reach maximum stack depth.

01:55:52:392 METHOD_ENTRY [EXTERNAL]|01pK0000000bnon|AffiliationTriggerDispatcher.afterDelete(TriggerParameters)
01:55:52:392 VARIABLE_SCOPE_BEGIN [93]|this|AffiliationTriggerDispatcher|true|false
01:55:52:392 VARIABLE_ASSIGNMENT [93]|this|{}|0x1a58d93c
01:55:52:392 VARIABLE_SCOPE_BEGIN [93]|arg0|TriggerParameters|true|false

The method (below) at line 93 is invoked but line 94 is never executed and never shows up in the debug logs.

public virtual override void AfterDelete(TriggerParameters tp) {
        System.debug('line #94: entered AfterDelete method');
        if(!isAfterDeleteProcessing) {
            isAfterDeleteProcessing = true;
            execute(new AffiliationAfterDeleteTriggerHandler(), tp, TriggerParameters.TriggerEvent.afterDelete);
            isAfterDeleteProcessing = false;
    }
    else execute(null, tp, TriggerParameters.TriggerEvent.afterDelete);
}

The event which causes the trigger to run is a simple test for deleting affiliations. Deactivating every affiliation workflow and a Salesforce NPSP affiliation trigger made no difference. This method is part of a 1 trigger framework I've used elsewhere without trouble.

Any thoughts on how I can find out how the afterDelete method is being called? Thanks in advance.

Following sfdcfox's helpful suggestion, I added a checkpoint at my debug line, #94, which generates the following additional log line:

15:01:13:167 PUSH_TRACE_FLAGS [EXTERNAL]|01pK0000000bnon|AffiliationTriggerDispatcher|APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;NBA,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,INFO

However, I still don't see that line 94 is executed or what external event is invoking the afterDelete method over and over.

Can also attest to the fact that the afterDelete triggerhandler method(s), which the dispatcher class should be sending a message to, are never invoked either, which also indicates that the method body below is not entered.

checkpoint


Update: I eventually found the line of code that was causing this, or specifically the missing closing curly brace in the Trigger Factory class. It wasn't [EXTERNAL], as the log indicated. A more accurate log entry would have saved me a lot of time. Thanks everyone for your help.

  • 1
    something to consider as it sounds like your code is doing cascading deletions -- maintain a static set of Ids that you've already deleted and ignore those when your execute method is called (within the execute method that is) – cropredy Feb 20 at 0:31
1

Checking if a line has "debugged" is usually not an indicator in regards to if a line has executed; it may have been truncated because of log size or omitted because of the debug level in your trace flags. If 93 is the method signature, and is called, 94 must have been called. Consider using the Developer Console and setting one or more checkpoints. Simply open your code in the Developer Console, set the appropriate debug levels (Apex must be INFO or higher), then try to run your DML operation. You should see not only that the line executed, but also the contents of the heap at that point in execution. This should aid you in troubleshooting further.

  • Thank you for the suggestion. I'm still not seeing execution of the debug expression. – Cleverlemming Feb 19 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.