You need to sign in to do that
Don't have an account?
vasanth kumar 6
Need to truncate salesforce table (custom object) using apex
The table is huge and comprises more than 1 lakh records or may be 2 lakh..
The below apex code is of less help because of the limit set ..in our environment it is 10000...
delete [select id from <object_name> limit <limit#>]
Is there any other option to delete the records using some sort of iteration.. how to achieve?
Pls help..
Thanks
Kumar
The below apex code is of less help because of the limit set ..in our environment it is 10000...
delete [select id from <object_name> limit <limit#>]
Is there any other option to delete the records using some sort of iteration.. how to achieve?
Pls help..
Thanks
Kumar
- In the start method of batch class get the records from the object using database.getquerylocator
- In the excute method write the logic to delete the record. The excute method will process the record based on the batch size
- Then in the finish method you can send email to the admin or any other person in your org which will be excuted only after processing all records.
Simple batch apex codeRefer this link to understand more about batch apex class - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm
Thanks,
Karanraj (http://www.karanrajs.com)
- From Setup, click Create | Objects.
- Click an object name to go to the object’s detail page and click Truncate.
- In the Confirm Custom Object Truncate window, review the warning and then enter the name of the object to truncate in the empty field.
- Click Truncate.
Make sure to read this link before you are going to perform this action - https://help.salesforce.com/HTViewHelpDoc?id=dev_object_trunc_overview.htm&language=en_US#TruncatingObjectsOverview (https://help.salesforce.com/HTViewHelpDoc?id=dev_object_trunc_overview.htm&language=en_US#TruncatingObjectsOverview)