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
Newbie  2014Newbie 2014 

How to truncate unused ActivityHistory (read-only object?) records!

Hello: Our salesforce CRM has huge amount of ActivityHistory records that are not in use anymore. Our storage limit almost exceeded and we need to purge those unused records ASAP. Some guidance on how to proceed will be life saver really!

I basically need to know HOW CAN I DELETE BUNCH OF RECORDS IF THE SOQL IS LIKE THIS: (SELECT id, subject from ActivityHistories where subject like 'opened email%' and  ownerid = '005600000019XBkAAM' AND lastmodifieddate < blah blah). Salesforce docs says activityhistory is a read-only object (http://www.salesforce.com/us/developer/docs/officetoolkit/Content/sforce_api_objects_activityhistory.htm), if so then how can I truncate the records then? Which tool to use and how?

Please note I tried few things as described below, but didn’t help.

1. I tried to pull activityhistory via excel connector to get the record ids but it kept failing due to internal server error with exception code 5103. I can pull other objects but not this one, not sure why. Feedbacks will be appreciated.

2. I tried to pull the same list of ids thru developer console but after some research found the only way to access the activityhistory object is a nested query format; I used the SOQL below:

SELECT (SELECT id, subject from ActivityHistories where subject like 'opened email%' and  ownerid = '005600000019XBkAAM') FROM Account limit 1000

But the output format I get is like [{“id”: 005600000019XBkAA”, “subject”:…}] which does not serve my purpose. All I need is a select statement returning two columns  - activityhistory.id and activityhistory.subject so that I know total number of rows. How to get the list list I need then?


Thanks very much in advance!
Newbie  2014Newbie 2014
I'd like to add that I tried to access the object via dataloader but it does not even show up on the objects list. If excel connector, dataloader none of them can access the activityhistory table, how else can i delete rows from it? Apex code is it?