You need to sign in to do that
Don't have an account?
HGS
Delete trigger not working in Master-Detail object deletion.
Hello Community !!
We have 2 custom object, in master-detail relationship.
When master record is deleted, the associated detail records are also deleted automatically.
And, we have a after-delete trigger on the detail object.
The problem is, that though the trigger works fine when we delete the detail records directly, it does not fire when the master is deleted, and thus the detail records are deleted.
Any pointers ?
Triggers are only invoked for data manipulation language (DML) operations that are initiated or processed by the Java
application server. Consequently, some system bulk operations do not currently invoke triggers. Some examples include:
• Cascading delete operations. Records that did not initiate a delete do not cause trigger evaluation.
• Cascading updates of child records that are reparented as a result of a merge operation
• Mass campaign status changes
• Mass division transfers
• Mass address updates
• Mass approval request transfers
• Mass email actions
• Modifying custom field data types
• Renaming or replacing picklists
• Managing price books
All Answers
I'm not sure why this is the behavior in Salesforce. But as a workaround, why not add the same delete trigger logic from the detail table onto the delete trigger logic of the master table? Will this work? :)
Best Regards,
Kerwin
:-)
Yes, I've already thought about that work-around, and would have to do it if there isn't any solution.
But was wondering, is there a constraint / bug, as this would affect a lot of code that we regularly write on the same lines.
Triggers are only invoked for data manipulation language (DML) operations that are initiated or processed by the Java
application server. Consequently, some system bulk operations do not currently invoke triggers. Some examples include:
• Cascading delete operations. Records that did not initiate a delete do not cause trigger evaluation.
• Cascading updates of child records that are reparented as a result of a merge operation
• Mass campaign status changes
• Mass division transfers
• Mass address updates
• Mass approval request transfers
• Mass email actions
• Modifying custom field data types
• Renaming or replacing picklists
• Managing price books
This bevavior:
comes as quite a surprise.
I have a "before delete" trigger on the last detail object of a master-detail relationship chain intended to propagate the cascading delete to a second master-detail chain. (The total number of master-detail relationships I need exceeds the current allowed maximum.) This seemed like a clean and simple approach but is not sufficient given the above.
Please give more emphasis in your documentation to this. I don't remember ever seeing it in the documentation.