I have a custom Object MyObject__c which has one field Contact__c lookup on Contact object and trigger on it. I want trigger to update ContactName field of MyObject__c when ever Contact object is deleted.I could see that LastModifiedDate of MyObject__c is getting updated on Contact record delete but trigger is not fired.
trigger ContactNameUpdate on MyObject__c (before insert,before update) {
List<MyObject__c> stObjects = Trigger.new;
system.debug('Inside trigger '+JSON.serialize(stObjects));
for(MyObject__c st : stObjects){
st.ContactName__c = st.Contact__r.Name;
}
}
What I am missing in above code? Please leave comment if problem is not clear.
Thanks