Skip to main content
amber_boaz_2f60c1
Contributor ⭐️⭐️
May 30, 2017

Tool to purge UsageData

  • May 30, 2017
  • 8 replies
  • 58 views
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

    azhar_uddin
    Helper ⭐️⭐️
    May 30, 2017
    Hi, 
    You want to delete all records and make UsageData object empty or just the scorecard measure in UsageData empty ?

    Thanks 
    amber_boaz_2f60c1
    Contributor ⭐️⭐️
    May 30, 2017
    Delete all records in the UsageData object.
    azhar_uddin
    Helper ⭐️⭐️
    May 30, 2017
    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 🙂
    smorrisgainsightcom
    Helper ⭐️⭐️⭐️
    May 30, 2017
    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.
    amber_boaz_2f60c1
    Contributor ⭐️⭐️
    May 30, 2017
    Right, and we have +-24million records in UsageData right now. 
    Only 2400 times! 🙂
    azhar_uddin
    Helper ⭐️⭐️
    May 30, 2017
    Ouchh.. !! You will need a script that deletes in batches

    😞
    smorrisgainsightcom
    Helper ⭐️⭐️⭐️
    May 31, 2017
    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.
    amber_boaz_2f60c1
    Contributor ⭐️⭐️
    May 31, 2017
    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.