The Problem
We're experiencing a problem where users are getting an "Insufficient Privileges" message when using an <apex:commandButton>
to view Activity History. The users are the Lead owners.
The Setup
We use a Visualforce wrapper for the Lead, embedding the standard layouts with <apex:detail inlineedit="true"/>
. After this we have custom related lists, including one for Activity History
that only shows users their own activities.
Relevant VF:
<apex:pageBlock title="Activity History" id="myActivities">
<apex:pageBlockButtons location="top">
<apex:commandButton value="View All"
action="{!URLFOR($Action.Activity.ViewAll, Lead.Id)}"/>
</apex:pageBlockButtons>
// Other code
</apex:pageBlock>
When a user clicks this "View All" button, they get the following message:
Insufficient Privileges You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary
Debugging
If I add the standard Activity History related list back to the page layout then my custom button works. As soon as I remove the standard related list my button breaks again. Inspecting the URL the two buttons generate did not yield much, either:
The standard button uses the following JavaScript in the onclick event:
navigateToUrl('https://cs2.salesforce.com/ui/core/activity/ViewAllActivityHistoryPage?retURL=https%3A%2F%2Fc.cs2.visual.force.com%2Fapex%2FviewLead%3Fid%3DredactedLeadId%26sfdc.override%3D1&id=redactedLeadId','RELATED_LIST','all');
The link generated by {!URLFOR($Action.Activity.ViewAll, Lead.Id)}
:
https://cs2.salesforce.com/ui/core/activity/ViewAllActivityHistoryPage?retURL=https%3A%2F%2Fc.cs2.visual.force.com%2Fapex%2FviewLead%3Fid%3DredactedLeadId&id=redactedLeadId
I can also replicate this in my dev org. Steps to replicate:
- Create/assign a user to the Standard User profile.
- Create/assign a Lead to the test user.
- Ensure the standard related list is on the page layout.
- Login as the test user.
- Record a completed Activity.
- Verify the test user can follow the View All Activity History button.
- Login as an Admin. Remove the Activity History standard related list.
- Login as the test user.
- Try to navigate to
https://[instance].salesforce.com/ui/core/activity/ViewAllActivityHistoryPage?id=[lead]
, replacing [instance] and [lead] with appropriate values. - Receive
Insufficient Privileges
error.
Edit
- The View All Activity page is the standard Salesforce page and is not overridden at all.
- Trying to navigate directly to
https://cs2.salesforce.com/ui/core/activity/ViewAllActivityHistoryPage?id=[lead]
fails when the related list is hidden.
Update 2013-Dec-19
It turns out that this happens even with the default System Admin profile.