I have around 47 objects and need to delete records from these objects but these objects are related by master-detail and lookup relations.

I have to go through relation of each of these objects to find which object records should be deleted first and then next and next so on.. this takes lot of time. Is there a easy way of doing this?

  • What problem are you experiencing? Generally speaking, you can delete records in any order you like, except for some standard relationships.
    – sfdcfox
    Commented Sep 2, 2019 at 3:44
  • I thought we will get errors like this record is in use and cannot be deleted if we don't delete in specific order(first master then detail and so on..)
    – javanoob
    Commented Sep 2, 2019 at 3:56
  • That only applies for Master-Detail where "prevent deletion" is enabled. For normal lookup fields, and master-detail relationships that have "cascade deletion" enabled, the order does not matter.
    – sfdcfox
    Commented Sep 2, 2019 at 3:59
  • That helps me for now. Can you post that as answer, so that I can close this question. Thanks again for your time.
    – javanoob
    Commented Sep 2, 2019 at 4:02

1 Answer 1


Unless your master-detail relationships are set to "prevent deletion", the order of deletion generally does not matter. For lookup fields, the field will simply be nulled (made empty) if you delete the parent, and for master-detail relationships with cascade deletion, deleting the master also deletes all child records as well. In most cases, this means that the order of deletion does not matter. If this is just a one-time mass delete, you might just edit the master-detail relationships to the "cascade delete" mode, delete the master records, then change it back when you're done.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .