Can I create a list of ActivityHistory or OpenActivity records?

I tried to create a table based on a model of the ActivityHistory object, but I get this error when I try to view the page:

1. An error occurred while attempting to perform the following SOQL query: SELECT Id,ActivityType,IsTask,Subject,Status,Priority,Location,ActivityDate,Description,Owner.Name,OwnerId FROM ActivityHistory WHERE ((WhatId = ‘a0Gd000000GApaJEAT’)) ORDER BY LastModifiedDate DESC LIMIT 101 Error:entity type ActivityHistory does not support query
Am I not going to be able to do this?

I think that it’s only possible to do relationship queries on the history object for example history for one Account, but not for the entire object

The ActivityHistory and OpenActivity objects are actually available for use in Skuid (or in any Visualforce custom development) – Salesforce exposes them via the API, but they cannot actually be used except for within Salesforce internal code. Instead, do separate queries on the Task or Event objects. To just get Open Tasks, add an “IsClosed != true” condition, or to get just Completed Tasks, do a Condition with “IsClosed != false”. (I think that in a future release of Skuid we may make it so that these objects don’t show up in the list of possibilities, since they don’t support querying or any of the CRUD operations).

Also, I’m currently working on a tutorial for making an “Activities Tab” that will include the Open Tasks and Closed Tasks related lists and some nifty JS snippets (thanks Zach) to mark tasks completed & view the full conversation without leaving the page :slight_smile: Hopefully it’ll get published next week.

I’m definitely interested in seeing that as soon as you have it.

Ta da! Here is the tutorial. Let me know if it was helpful.

I’m having similar issues with trying to load ActivityHistory for a Contact. I’m able to bring in the records as a child relationship under my Contact, but I can’t display these records as rows on a table. Any help with this would be appreciated, thanks!

This tutorial was very helpful! However, I don’t see anything about accessing ActivityHistory. Is this something you’ve been able to resolve since?


I think you’ve gotten about as far as you’re able to. Querying the “ActivityHistories” Child Relationship is the best way / only way to get at ActivityHistory data, but Skuid doesn’t let you display Child Relationship data as rows in a Table, so your best bet is to use a Template Component to format the data using Merge Syntax to “look” like a table. This is a bit of a hack, that may not look good in the future if Skuid changes its CSS, but it’s a temporary workaround.

Here’s the XML for a sample page:

{{FirstName}} {{LastName}} {{Model.label}} <div class="nx-skootable"> <table class="nx-skootable-data"> <thead> <tr> <th>Subject</th> <th>Date</th> <th>Who</th> <th>Related To</th> </tr> </thead> <tbody class="nx-list-contents"> {{#ActivityHistories.records}} <tr class="nx-item"> <td>{{Subject}}</td> <td>{{ActivityDate}}</td> <td>{{Who.Name}}</td> <td>{{What.Name}}</td> </tr> {{/ActivityHistories.records}} </tbody> </table> </div>

Here’s some example contents of the Template for the Template Component (you have to have “Allow HTML” enabled):

{{#ActivityHistories.records}} {{/ActivityHistories.records}}
Subject Date Who Related To
{{Subject}} {{ActivityDate}} {{Who.Name}} {{What.Name}}

Thanks Zach, this was perfect! I didn’t think of using templates for this, that was a great idea. In case anyone tries something like this in the future, make sure you include AcitvityHistories as a child relationship in your model, and set Properties > Fields to Order Records By to “ActivityDate DESC NULLS LAST, LastModifiedDate DESC”, otherwise you’ll get an error.