• Amil Abdallah
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
I have created a salesforce page which displays a datatable that is populated with an Account's activity history.  I have created this table view as opposed to utilizing the related list view because the activity history gets very convoluted with email responses.  The clients have requested a table view in which to filter out emails and other types of activities so that it's much more managable/easier to read. 

In doing my research, I have come to find that the Activity History table is special and cannot be queried directly.  Inconvenient as it is, I went ahead and created a soql query which joins the activity history to the account object as seen below:

[select id, name, ownerid,
            (select id, subject, whoid, whatid, accountid, ownerid, activitydate, description, status, activitytype, istask, CreatedById from ActivityHistories WHERE not(subject like 'mass email%' OR subject like 'pardot list email%') ORDER BY activitydate DESC)
            from account
            where id = :ApexPages.currentPage().getParameters().get('id')]

The query works and I am able to display the data within the table with the exception of two fields, whoid ('name/contact' field) and whatid ('related to' field). When I run this query in the Force.com explorer I clearly see value for those fields populated in the results, however, when I query within the developer console, those fields return null. I am unable to display these fields in my table as they show up null in the result set. Does anyone know why I am unable to get these results within my apex code/visualforce page despite the fact that I can see the results in the force.com explorer? Any help is greatly appreciated.
I have created a salesforce page which displays a datatable that is populated with an Account's activity history.  I have created this table view as opposed to utilizing the related list view because the activity history gets very convoluted with email responses.  The clients have requested a table view in which to filter out emails and other types of activities so that it's much more managable/easier to read. 

In doing my research, I have come to find that the Activity History table is special and cannot be queried directly.  Inconvenient as it is, I went ahead and created a soql query which joins the activity history to the account object as seen below:

[select id, name, ownerid,
            (select id, subject, whoid, whatid, accountid, ownerid, activitydate, description, status, activitytype, istask, CreatedById from ActivityHistories WHERE not(subject like 'mass email%' OR subject like 'pardot list email%') ORDER BY activitydate DESC)
            from account
            where id = :ApexPages.currentPage().getParameters().get('id')]

The query works and I am able to display the data within the table with the exception of two fields, whoid ('name/contact' field) and whatid ('related to' field). When I run this query in the Force.com explorer I clearly see value for those fields populated in the results, however, when I query within the developer console, those fields return null. I am unable to display these fields in my table as they show up null in the result set. Does anyone know why I am unable to get these results within my apex code/visualforce page despite the fact that I can see the results in the force.com explorer? Any help is greatly appreciated.