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
Jaya Sankar BagepalliJaya Sankar Bagepalli 

need to delete custom object records

Hello all,

i have a custom object called  Interests__c

we have discontinued  using this object and it has 240,000 records in it.

we need to get rid of these.

on top of that  we have master detail and look ups  which is not allowing to truncate

User-added image

can you guys help me with this ?

Kind Regards,
Jaya
 
karthikeyan perumalkarthikeyan perumal
Hello Jaya, 

1. export  records  in to CSV file with record ID. 
2. Delete relation of this object with other object  (objetc master and lookup) (use schema builder to verify the relationship).
3. split the CSV file in to 5 or more file for avoid  the governer limits.( Example 1 file Contain 20,000 somthing  like) as per your convinent. 
4. use dataloader or workbench  to upload file once its complated. move on to next file.

(OR) 
if you dont want you the object anymore, use schema builder to check the relationship and reference. delete the relationship with other object and
Truncate the object from  Create-->Object-->Interests__c-->Truncate.

Hope it will help you. 
makr best ANSWER if its work for you.

Thanks
karthik
Dilip_VDilip_V
Hi Jay,

Follow this steps 

1.First find out the relationships(Look up and Master detail).Convert master detail relationship  to look up relationship.
2.Delete references and relationship fields on child objects.
3.Write a query to retrive 9999 record of type interest__C and delete(10000 is limit).
List<Interest__c> Interests=[select id,name from Interest__C limit 9999];
Delete Interests;

Thanks.

 
Adarsh Sharma 4Adarsh Sharma 4
Hi Jay,

Follow this steps 

1.go into developer console >>debug>>open execute anonymous
2.  for( Interests__c oInterests:[select id,name......(all fields)........ from  Interests__c limit 200]){
delete oInterests;
}
3.you can build this query from schema .you can also incresae and decrease limit of records,
Michael TomarMichael Tomar

I'd like to advise you Skyvia online tool, you can read their step-by-step tutorial here https://skyvia.com/blog/how-to-mass-delete-records-from-salesforce-using-sql-or-data-loader

They also have ready-made queries, this one (https://skyvia.com/gallery/salesforce-mass-delete-custom-objects-records) may be helpful in your case:

DELETE FROM "Custom_object" WHERE "Specific_field"= 'Specific_value'