+ Start a Discussion
boihueboihue 

Bulk delete (Cascade delete)

Hi,

I have two objects Department and Employee that is joined to Department object with the DeptID field (1 Department can have 0 or n Employees but the Employee object is not the Related list of Department). I want to write a trigger when deleting the any Department then all Employees of this Department will also be deleted. I want to use the Bulk Delete (or Cascade Delete) method to avoid the Governor limit of Salesforce. All helps will be appreciated.

Thanks and best regards

Cool_DevloperCool_Devloper

Well, fecth all the related records in the trigger and then add them in a list.

 

Then do a bulk delete .... if there are too many of them to delete in a trigger, then you can make some asynchronous calls to do the same for you.

 

Hoep this helps!!

Cool_D