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
SeattleEliSeattleEli 

Is there an age limit on records returned from SOQL query?

When I submit a SOQL query, it appears that no records older than one year are returned. Is this indeed the designed behavior? Is there a way to retrieve records older than one year via a SOQL query?

Example:
Select from Event where OwnerId = ''

The results include all the Event records owned by the owner id specified, except that events older than one year are not in the result set.

Can anyone tell what the absolute limits are in this regard and what if any options I have to retrieve records older than one year? I couldn't find any mention of this limitation in the message boards or the API documentation.

Thanks!
ScotScot

This limitation is documented, but it's not easy to find.

It's specific to task and event records. In the API documentation, you'll find it in Sforce Objects / Events, towards the end of the page. To quote:


Archived Activities

Sforce archives older events and Tasks according to the criteria listed below. In the Salesforce user interface, users can view archived activities only in the Printable View or by clicking View All on the Activity History related list or by doing an advanced search. However in the Sforce API, archived activities are not accessible.

Sforce archives activities according to the following criteria:

    • Events with an ActivityDateTime or ActivityDate value greater than or equal to 365 days old
    • Tasks with a Closed flag value of True and an ActivityDate value greater than or equal to 365 days old
    • Tasks with a Closed flag value of True, a blank ActivityDate field, and a create date greater than or equal to 365 days ago

    If you use the Sforce API to insert activities that meet these criteria, the activities will be archived during the next run of the archival background process.


    You can get the information in the weekly export files ...
    Nathan ShinnNathan Shinn

    Is there any way around this using SOQL?

     

    I have a client that is converting data from one org(they bought this company) to another. They want to convert Tasks but our query only gets tasks that are greater than one year old.

    Thanks,

     

    Nathan

    SuperfellSuperfell
    you can use the queryAll method to access archived tasks & events.
    Nathan ShinnNathan Shinn

    Thanks!

    I tried that earlier but ten got derailed on other things. I put it back in and it works.

    Nathan

    Nathan ShinnNathan Shinn

    BTW:

    Do you know how t delete Partner records via the API?

    They don't have an ID so I can't use a binding.delete() method can I?

    Nathan