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
carramrodcarramrod 

Null Pointer Exception on BeforeDelete trigger

getting a null reference exception on the line in bold, I don't understand why...
Am I passing the wrong kind of trigger parameter (Trigger.new)?

System.NullPointerException: Attempt to de-reference a null object

Trigger:
trigger tAccountRecordDeleteBefore on Account (before delete) {
    cAccountRecordDeleteBefore.TrackDelIntegrationAccount(Trigger.new);
}

Called Class:
public class cAccountRecordDeleteBefore {
    public static void TrackDelIntegrationAccount(Account[] accs){
        List<Deleted_Accounts__c> delList = new List<Deleted_Accounts__c>();
        Deleted_Accounts__c acct = new Deleted_Accounts__c();
        for(Account a:accs){
                if(a.Sent_To__c == true){
                    acct = new Deleted_Accounts__c();
                    acct.Name = a.ID;
                    acct.Last_Sent_Time__c = a.Sent_Time__c;
                    delList.add(acct);
                }//end if
        }//end for
        if(delList.size()>0){
            insert delList;
        }
    }
}



Message Edited by carramrod on 12-18-2008 11:22 AM

Message Edited by carramrod on 12-18-2008 11:25 AM
aalbertaalbert
Trigger.new is not available on a "before delete" trigger context.
Try Trigger.old


More information here: http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_triggers_context_variables_considerations.htm

carramrodcarramrod
that did it!
Thanks.