[SalesForce] Are there limitations on querying Tasks

I am trying to bulk re-parent activities from one object to a new object.

When I use the following SOQL query I get no results even though I know the record exists:

SELECT Id,WhatId FROM Task WHERE Id = '00T8000000jbngc'

I'm using workbench.developerforce.com to run my SOQL query.
I used the 15 digit id and I also used the 18 digit id. In both cases I got the following message:

Sorry, no records returned.

I then manually migrated the record and tried the query again and it then returned the record.

Are there limitations on querying old tasks? By modifying the record did I cause it to become query-able?

Best Answer

You're running into the Archived Activities limitation. Events older than 365 days and tasks closed more than 30 days don't appear in "normal" queries. This is a performance benefit. If you're using Apex Code, use the ALL ROWS SOQL modifier to query those records, and if you're using the Data Loader or another tool, use the QueryAll function (e.g. Export All in the Data Loader UI). When you modify an activity it becomes "current" for a while and can be viewed in a normal query. Upon the next time that the Archived Activities task runs, it will again disappear if it meets the criteria.

Related Topic