• valentijnnk
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hi there,

I have two objects: (the standard) Contact and a CustomObject. The relationship between the two is a lookup-field on the Contact, named "CustomObjectID". 
I have a checkbox on the CustomObject-record; this checkbox shows whether a Custom Object has a Contact related to it.

Now, when I delete a Contact, I want the checkbox on the related Custom Object to be unchecked.

I currently use this apex trigger:

trigger CustomObjectDelete on Contact (before delete) {
for (Contact c : Trigger.old) {
c.CustomObject__r.Checkbox__c = false;
  }
}

But it gives error:  "System.NullPointerException: Attempt to de-reference a null object:"

Many many thanks in advance !

KR, Valentijn
Hi there,

I have two objects: (the standard) Contact and a CustomObject. The relationship between the two is a lookup-field on the Contact, named "CustomObjectID". 
I have a checkbox on the CustomObject-record; this checkbox shows whether a Custom Object has a Contact related to it.

Now, when I delete a Contact, I want the checkbox on the related Custom Object to be unchecked.

I currently use this apex trigger:

trigger CustomObjectDelete on Contact (before delete) {
for (Contact c : Trigger.old) {
c.CustomObject__r.Checkbox__c = false;
  }
}

But it gives error:  "System.NullPointerException: Attempt to de-reference a null object:"

Many many thanks in advance !

KR, Valentijn