Under Consideration

Tool to purge UsageData


We've moved to Scorecard 2.0 and no longer need the data in the UsageData object. In order to get rid of that data, we have to use DataLoader and hard delete. That's do-able, but time consuming.
I tried using Truncate, but it's not an option for custom objects in managed packages.
I'd like a tool to remove all data from UsageData so I don't have to do that manually.

8 replies

Userlevel 5
Hi, 
You want to delete all records and make UsageData object empty or just the scorecard measure in UsageData empty ?

Thanks 
Delete all records in the UsageData object.
Userlevel 5
If you have access to Developer console then you can run this Apex code.

delete [SELECT Id from JBCXM__UsageData__c];

**** IMPORTANT **** 
This deletes every thing in UsageData permanently. 
***** Please use caution *****

Thanks 🙂
Userlevel 6
Yep this will work, however you'll need to add a LIMIT 10000 clause as SFDC only allows 10k records to be deleted at a time.
Right, and we have +-24million records in UsageData right now. 
Only 2400 times! 🙂
Userlevel 5
Ouchh.. !! You will need a script that deletes in batches

😞
Userlevel 6
Amber what I'd do is use workbench to export all records (choose bulk csv option) from the Usage Data object.  You can then run a delete job directly from Workbench using SFDC's Bulk API which batches them for you in 10k jobs.

All you'll need to do is map the Id in the file to Id in the delete option.  If you have any questions, please let me know.
Because of the data volume, Workbench times out on me when I try to pull this many records.
As best I can tell our only option is to use the DataLoader.

Reply