[SalesForce] How to i invoke a child object trigger when a parent object trigger delete action invoked

I have 3 objects like superParent Parent Child..

I am updating the count of Parent and Child object records on SuperParent in two different fields and it is working fine when i am doing manually.

when Parent Object record is deleted Child object record also deleting because of master detail relation.In that scenario only Parent Records are updating how can i call child object trigger when parent deleted.

Best Answer

On the assumption that your delete logic is embedded in the Child trigger and you want to execute that logic upon some event in the Parent object ....

  1. Triggers can only be invoked when a DML statement occurs and the trigger is registered to handle that DML event (insert, update, delete, undelete - and in before/after such event)
  2. Move your logic out of the Child trigger into a class that can be called both from the Child trigger and from the Parent trigger

More generally, this is covered under the Separation of Concerns pattern as ably described by Andrew Fawcett here.