+ Start a Discussion
Christos KolonisChristos Kolonis 

Trigger is not deleting the records which i have to delete


I need a trigger which will run when the Opportunity is in stage "X". I have a handler apex class which checks if the Opportunity is in this stage and if it is, gets the Opportunity's attachments and deletes them. This Stage is updated by another apex class and trigger from another custom object. So, if i select manually the stage it functions as it should but if the stage is updated by the apex, my new trigger is not running. I am using before insert trigger. Any thoughts??

Thank you!
ShirishaShirisha (Salesforce Developers) 
Hi Christos,


I don't think before insert works to delete the child record(since an attachments considered as Child record for the Object).I would suggested you to go with the Before Update trigger as suggested in the below thread.


Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
Christos KolonisChristos Kolonis
Hello Shirisha,

My fault, my trigger is before update. Miss spelling!