Wednesday 31 December 2014

Truncating Custom Objects


Truncating custom Object allows you to remove all of the object's records, while keeping the object and its metadata. When you truncate a custom Object Salesforce places a truncated object in the Deleted Object list for 15 days. It appears in deleted object list as objectname_trunc.

NOTE : During this time, the truncated object and its record continue to count against your org limits.

NOTE : Truncated Objects can not be restored to their original state.

Truncating object is a fast way to permanently remove all of the records from an object, while keeping object and it metadata intact for future use.

Lets play with truncation

I have created a custom object "TestObject" and inserted few records.

On object defination page I can not see "Truncate " button 



to enable Truncate go to Setup -> Customize -> User Interface and select "Enable Custom Object Truncate "



on saving it a new button "Truncate " started to appear on custom objects definition page.




Clicking on Truncate button will delete all the records present ( from recycle bin as well) and put the record in another object named as objectname_trunc in deleted object list.




Truncating is much faster than batch delete.

Important points
1. You can not truncate custom objects if they are referenced by another object through a look-up field.
2. You can not truncate custom objects if they are on Master side of a Master-Detail relationship.
3. You can not truncate custom objects if they contains geolocation field.
4. You can not truncate custom objects if they contains field marked as externalId.
5. Truncating custom object will remove custom object's history.
6. Truncating custom object erase all records currently in recycle bin.
7. Truncating object will erase related Tasks, Events, Notes, Attachments for each deleted record.

Salesforce preserves
1. Workflows, Actions, Triggers.
2. Sharing rules associates with custom object.
3. Validation Rules and Approval process.


Reference : Truncating Custom Objects Overview

No comments:

Post a Comment