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
taramstarams 

Deleting archived tasks to clear space

Hello,

 

I ran into storage space issues on my Full Sandbox. On inspecting Storage Usage, I found that Task records were taking up  the bulk of storage. There are around 100 K Task records. Also when I run  the query  - Select count() from Task - it returns zero records. So my assumption is that all of these tasks are archived.

 

 I need to delete these archived Tasks, but I 'm running into road blocks. These are the approaches I have tried -

 

  1. Mass Delete option from the UI. This will delete 250 records in one shot. This is going to be very cumbersome considering I have 100k records
  2. Wrote a Batch Apex class to delete tasks. But am unable to retrieve archived Tasks. The query  - 'Select Id from Task  limit 50000 all rows'  - always returns zero records. I read that queryAll( ) is the way to go to retrieve archived records, but is there a way to use queryAll in a Batch Apex class?
  3. DataLoader - this seems to be the fastest way to delete records, in combination with the Bulk API. But the same problem of retrieving archived tasks exists here too.  There are zero rows exported I export Task using this tool. I read somewhere that archived records can't be exported using DataLoader ?

What are the alternatives that I have ? Please advise.

 

Regards,

Tarams

  

nylonnylon

Hi,

Apex Data Loader 22.0 has got 'Export All' button and it seems to be able to retrieve archived records.

Siddharth Birari.ax1164Siddharth Birari.ax1164
When you select 'Export All' from Apex data loader, you would get all the Task records, i.e. Active as well as Arvhived.
Better you put one more clause while writing SOQL query [Select Id From Task where IsArchived = True];

With this, in your batch class you would get all the archived Task records.

Hope that helps.

Alec Davis 13Alec Davis 13
Can you export archirved Tasks records via Bulk API, this doesn't seem possible? Export All will hit our 24 hour API limits.