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
AFTAB ALI 6AFTAB ALI 6 

Before delete example code ?

SwethaSwetha (Salesforce Developers) 
HI Aftab,
This event runs the block of code before the data is deleted from the database. Operations such as preventing data deletion from the database can be handled using this event.
 
SYNTAX:
trigger triggerName on objectName (before delete) {
   // Block of code
}
 
SCENARIO:
We are having the requirement to prevent deletion of Account record if it has parent Account associated with it.
 
APEX TRIGGER:
trigger AccountMainTrigger on Account (before delete) { // Specifying the event.
    createContactClass obj=new createContactClass(); // Creating instance of the class.
    if(trigger.isbefore && trigger.isdelete) // Using context variable.
    {
     obj.method1(Trigger.old); // Passing records to apex method.
    }
}

Reference: https://www.srinivas4sfdc.com/2013/12/before-delete-trigger-in-salesforce.html

Related posts:
https://salesforce.stackexchange.com/questions/288342/what-is-the-difference-between-before-delete-and-after-delete
https://stackoverflow.com/questions/69446191/why-does-salesforce-on-before-delete-trigger-delete-record-before-processing

If this information helps, please mark the answer as best. Thank you