function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mh1974mh1974 

Cascading deletes - why doesn't it fire the delete trigger?

All,  I have a custom object that is is the 'detail' in a Master-Detail relationship with Opportunity. When this custom object is created,  it creates a task for the user which then appears in their My Tasks section on the Home Page. 

 

Because Task objects are not allowed to participate in a Lookup or Master-Detail relationship,  the custom object holds the task ID and if it is deleted it deletes the task too when the custom object delete trigger is fired.

 

All this works fine,  but,  if I delete the Opportunity, the custom object is deleted whilst the task is not.  It looks to me as though the delete trigger does not fire under these cirumstances,  can anyone shed any light on this?

 

Thanks,

 

Matt

Best Answer chosen by Admin (Salesforce Developers) 
mh1974mh1974

Straight from the Apex Code Developer's Guide,

 

"...

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.

..."

 

 

Click here to see the whole article.

All Answers

sunil316sunil316

Yes,  delete trigger could not fire under these cirumstances.

cos trigger is involked, when v perform certain action(like clicking a button). and in this case due to master detail relationship, detail object automatically gets deleted... (without clickin a delete button) and trigger is not involked, thus task field doesnt get deleted.

mh1974mh1974

Straight from the Apex Code Developer's Guide,

 

"...

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.

..."

 

 

Click here to see the whole article.
This was selected as the best answer