Can I create a list of ActivityHistory or OpenActivity records?

edited December 13, 2019 in Questions
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?


  • edited February 16, 2015
    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
  • edited March 2, 2017
    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).
  • Anna WiersemaAnna Wiersema 🛠️ 
    edited December 13, 2019
    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 :) Hopefully it'll get published next week.
  • edited November 19, 2015
    I'm definitely interested in seeing that as soon as you have it.
  • Anna WiersemaAnna Wiersema 🛠️ 
    edited September 2, 2016
    Ta da! Here is the tutorial. Let me know if it was helpful.
  • edited September 2, 2016
    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!
  • edited September 2, 2016
    This tutorial was very helpful! However, I don't see anything about accessing ActivityHistory. Is this something you've been able to resolve since?
  • edited March 2, 2017

    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:

    <skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true" tabtooverride="Contact">   
            <model id="Contact" limit="1" query="true" createrowifnonefound="false" datasourcetype="salesforce" datasource="salesforce" sobject="Contact" type="">
                    <field id="FirstName"/>
                    <field id="LastName"/>
                    <field id="CreatedDate"/>
                    <field id="ActivityHistories" type="childRelationship" limit="10" orderby="LastModifiedDate DESC, ActivityDate ASC NULLS LAST">
                            <field id="Subject"/>
                            <field id="Status"/>
                            <field id="ActivityDate"/>
                            <field id="Priority"/>
                            <field id="WhoId"/>
                            <field id="WhatId"/>
                            <field id="Who.Name"/>
                            <field id="What.Name"/>
                    <field id="Birthdate"/>
                    <field id="AccountId"/>
                    <field id="Account.Name"/>
                    <condition type="param" enclosevalueinquotes="true" operator="=" field="Id" value="id"/>
            <pagetitle model="Contact" uniqueid="sk-3n-oLB-74">
                    <template>{{FirstName}} {{LastName}}</template>
                    <action type="delete"/>
                    <action type="clone"/>
                    <action type="share"/>
                    <action type="savecancel" window="self"/>
            <basicfieldeditor showsavecancel="false" showheader="true" model="Contact" mode="read" uniqueid="sk-3n-oLC-75">
                    <column width="50%">
                            <section title="Basics">
                                    <field id="FirstName"/>
                                    <field id="LastName"/>
                    <column width="50%">
                            <section title="Other Details" collapsible="no">
                                    <field id="AccountId"/>
                                    <field id="Birthdate"/>
            <template multiple="false" uniqueid="sk-3o1kUh-234" model="Contact" allowhtml="true">
                <contents>&lt;div class="nx-skootable"&gt;
    &lt;table class="nx-skootable-data"&gt;
                &lt;th&gt;Related To&lt;/th&gt;
        &lt;tbody class="nx-list-contents"&gt;
            &lt;tr class="nx-item"&gt;
            <styleitem type="background" bgtype="none"/>

    Here's some example contents of the Template for the Template Component (you have to have "Allow HTML" enabled):

    <div class="nx-skootable">
    <table class="nx-skootable-data">
                <th>Related To</th>
        <tbody class="nx-list-contents">
            <tr class="nx-item">

  • edited September 6, 2016
    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.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!