When I query ActivityHistory in my SOQL editor, I get back the correct results with the correct format of the activity date:

[{"CreatedById":"00534000009QnEtAAK","Subject":"Call","Description":"this should show up on the list","ActivityDate":"2016-07-04"}]

When I query within debug log the results I am getting back are:

11:01:49:035 USER_DEBUG [18]|DEBUG|the activity dates are: (Account:{Id=00154000005qE9oAAE, RecordTypeId=01280000000BeF5AAK}

Why is this happening?

My debug log is:

public List<SObject> tasksAndNotes {get; private set;}
//public List<SObject> t {get;set;}
public List<SObject> n {get;set;}
List<SObject> lstAcc {get;set;}

tasksAndNotes = new List<SObject>();
public List<SObject> ah {get;set;}
//t = [Select CreatedById, Subject, Description, CreatedDate From Task WHERE WhatId ='00154000005tAZ6AAM'];
lstAcc = [SELECT (Select CreatedById, Subject, Description, ActivityDate From ActivityHistories) From Account Where Id ='00154000005qE9oAAE'];
n = [Select CreatedById, Title, Body,CreatedDate From Note WHERE ParentId ='00154000005tAZ6AAM'];


//System.debug('the  tasks list is: ' + t);
System.debug('the  notes list is: ' + n);
System.debug('the activity dates are: ' + lstAcc);
System.debug('the tasksAndNotes list is: ' + tasksAndNotes);
  • ActivityHistories is not part of Account. Try System.debug('the activity dates are: ' + json.serialize(lstAcc)); – Ilya Lepesh Jul 20 '16 at 18:17
  • Interesting, I have never used serialized before. What I got back was: [{"attributes{"type":"ActivityHistory","url":"/services/data/v37.0/sobjects/ActivityHistory/00T54000002LmIOEA0"},"AccountId":"00154000005qE9oAAE","Id":"00T54000002LmIOEA0","CreatedById":"00534000009QnEtAAK","Subject":"Call","Description":"this should show up on the list","ActivityDate":"2016-07-04"}, It looks like it is all there...now let's just see if I can pull the info out to a VF page! – Olivia Jul 20 '16 at 18:36
  • @IlyaLepesh because I am able to see that the content is in tasksAndNotes with the serialize functionality, I should be able to pull the information out, right? I am getting no response from my VF page when I try to do this. Could you explain what the serialize is actually doing to allow us to view the content? – Olivia Jul 20 '16 at 20:51
  • Have you tried Task? Should have same records: SELECT Id, CreatedById, Subject, Description, ActivityDate FROM Task where whatid = '0013600000LtVvQ' – Ilya Lepesh Jul 20 '16 at 21:44
  • I actually need ActivityDate from ActivityHistory because it shows the closed date of the task. When I just query ActivityDate from Task is shows the due date. I only want to list the items that have been closed. – Olivia Jul 20 '16 at 22:29

Your Answer

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

Browse other questions tagged or ask your own question.