function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Activity History vs. Task



I created a Visualforce page for Contacts for looking at a filtered Activity History.  I ran into an issue where if I used the object "ActivityHistories", users got an Internal Server error; however, if I changed this to Tasks, the page rendered fine.


Does anyone know the difference here?  Looking at the Profile Management screen, I cannot see any specific setting options for Activity History that would explain this.


Below is the page for reference.  The line in question is the <apex:repeat> section, where if I change the value to {!Contact.ActivityHistories}, the page renders fine for me (Sys Admin) but not for other users.


Thank you.




<apex:page standardController="Contact"> <apex:pageBlock title="{!}"> You are viewing the {!}'s Activity History. <a href='/{!contact.Id}'>Back to Contact Record</a> </apex:pageBlock> <apex:pageBlock title="{!} Activity History"> <apex:repeat value="{!contact.Tasks}" var="task" > <apex:pageBlockSection title="{!task.Subject} ({!task.ActivityDate})" columns="1" rendered="{!IF(task.WhatId == null, true, false)}"> <apex:outputField value="{!task.Subject}" /> <apex:outputField title="Due Date" value="{!task.ActivityDate}"/> <apex:outputField value="{!task.OwnerId}"/> <apex:outputField value="{!task.LastModifiedDate}"/> <apex:outputField value="{!task.Description}"/> </apex:pageBlockSection> </apex:repeat> </apex:pageBlock> </apex:page>





Not sure what the ActivityHistory table exactly does. You don't need it though, since all completed tasks and events are also available in the corresponding objects.


I did have a look at the access to the ActivityHistory and found out it has NO(?) access at all:




Thanks Hermie, I see the access there.


I guess my curiousity is why the page works under my System Administrator  and doesn't error out gracefully under the other accounts (i.e. error message about permissions/access).  Displaying the Internal Server Error is less desirable than this.


Hi Andrew,


I'm not sure of the reason, but it may be because of the requirements listed at the bottom of this relevant Web Services API page.


Perhaps the issue is that the user you were testing with did not have "View All Data" permission?





In order to prevent performance issues while still providing the related list functionality, there are some restrictions on users who do not have “View All Data” permission. Such users must comply with the following restrictions:
  • In the main clause of the relationship query, you can reference only one record. For example, you cannot filter on all records where the account name starts with A, but must reference a single account record.
  • You cannot use WHERE clauses.
  • You must specify a limit to the number of rows returned, less than 500.
  • You must sort on ActivityDate and LastModifiedDate, descending order: ORDER BY ActivityDate DESC, LastModifiedDate DESC

After speaking with SF Support, they have advised that the fact that this results as an Internal Server Error (rather than something more graceful), its a bug that will be sent to the QA team.