3

I'm querying closed activities on a contact.

SELECT (SELECT Subject, ActivityDate, Description, IsTask, WhoId 
        FROM ActivityHistories)  
FROM Contact  
WHERE Id = '003e000000EQ8fm'

The above query returns 8 closed activities (7 tasks and 1 event).

If I run the following query on Task:

SELECT t.Subject, t.Id, t.HQ_Activity__c 
FROM Task t 
WHERE t.WhoId = '003e000000EQ8fm'

I get 3 records returned (a small subset of the 8 records returned from the activity history)

So, if there a 7 closed tasks that are returned in the activity history query and only 3 task records returned from the Task query, what is the criteria that stops the records from being returned in the task query? They are all closed, yet 3 records still pull up when I query the Task object and not all 7. Why? What is the criteria that filters out those additional 4 records? Is it a date that is hard-wired into Salesforce that removes them from the Task object after a certain amount of time?

1

You already identified the issue. Exactly, based on the date and once it is surpassed it moves the activities to history table because it would not no longer meaningful but yet it is important for various reports. It is the normal behavior in salesforce and you already find out. There is a field in Task object,

isArchived which is boolean and Salesforce updates it to true once the task is outdated and hence it is history. Its something salesforce managed internally.

|improve this answer|||||
  • 1
    But you can use ALL ROWS if you still want to query them once archived. – sfdcfox Apr 29 '14 at 18:26
  • yes @sfdcfox. I agree with you. Valid point. – Bforce Apr 29 '14 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.