1

I have written a very simple trigger logic and I am seeing something weird. Why can't I see something in the Developer Console or Debug Logs when I delete a record? But if I change the logic to After Delete I can see the text 'Hi' printed. Nothing really executes in the before Delete at the moment.

Trigger Logic:

if(trigger.isDelete && trigger.isBefore){
    sampleApexClass.PrintSomeValue();
}

Method:

public static void PrintSomeValue(){
   System.Debug('Hi');
}

Is there something wrong I am doing? Or what could be wrong here.

4
  • 2
    Post more of your trigger code. Is your trigger operating Before Delete?
    – greenstork
    Mar 21, 2014 at 0:32
  • You should have posted that as an answer :) thanks so much. There is about 1000 lines of code in this trigger and I got lost. Don't worry there is a few helper classes and no helper code is there!
    – subodhbahl
    Mar 21, 2014 at 0:36
  • Posted as an answer.
    – greenstork
    Mar 21, 2014 at 0:36
  • Quick question, I want to make a callout for a delete via the trigger and I am doing that before Delete. Apparently, the callOut is @future, and when I query the record, it's already gone. What would you advice on that? If anything.
    – subodhbahl
    Mar 21, 2014 at 1:20

1 Answer 1

4

There are two things that could be happening here. One is that your trigger does not operate in the Before Delete context. The other is that you could be looping through Trigger.New, which is empty in a delete trigger context.

EDIT: I see now that you said it works with after delete but not before delete so my second scenario is not valid, best to check if the Before Delete context is on your trigger.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .