1

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.

  • Triggers can only be invoked when a) they exist and b) a DML statement that a trigger is registered to handle is invoked. Are you trying to invoke trigger logic without doing DML? If so, perhaps moving trigger logic out of the trigger into a class would solve your problem – cropredy Apr 23 '14 at 16:21
2

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.