10

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:

  1. Create/assign a user to the Standard User profile.
  2. Create/assign a Lead to the test user.
  3. Ensure the standard related list is on the page layout.
  4. Login as the test user.
  5. Record a completed Activity.
  6. Verify the test user can follow the View All Activity History button.
  7. Login as an Admin. Remove the Activity History standard related list.
  8. Login as the test user.
  9. Try to navigate to https://[instance].salesforce.com/ui/core/activity/ViewAllActivityHistoryPage?id=[lead], replacing [instance] and [lead] with appropriate values.
  10. 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.

  • 2
    Salesforce support has sent my case to the Page Layout team. – Mike Chale Dec 19 '13 at 20:12
  • Have they acknowledged it is a bug yet? It is really odd behavior. – Jesse Altman Dec 20 '13 at 13:18
  • 1
    No, it has not yet been marked as a bug, but I think that's just because it hasn't reached the right team yet. – Mike Chale Dec 20 '13 at 13:37
5
+50

I can replicate the same thing that you are observing.

I have a "workaround". I was able to reverse engineer the Go to List >> links on the related list when there are more than the default number in the list (more than 5 for me) on the page.

gotolist

I built the following URL:

https://na15.salesforce.com/007?id=00Qi0000002djnG&rlid=RelatedHistoryList&closed=1

The rlid parameter specifies the related list.
The id parameter specifies the Id of the Lead.

This isn't as good as directly accessing the built-in $Action.Activity.ViewAll, of course, and it looks like you probably found a defect, but maybe you can use this in the mean time. It does work when the related list is not on the page layout.

  • That's really weird that crafting that URL works, but not using $Action. I'll definitely try that out as a workaround. – Mike Chale Dec 20 '13 at 13:35
  • Yeah. It really looks like a bug. – Peter Knolle Dec 20 '13 at 13:43
  • 2
    Wish I could double vote this up, sweet work around. – Ralph Callaway Dec 20 '13 at 23:02
  • 1
    With this as a feasible workaround while the Salesforce team works on the issue, I am going to award the bounty. Good find Peter. – Jesse Altman Dec 23 '13 at 17:04
2

I received a response from Backline Support:

The behavior reported in this case is expected. When the Activity History related list is not on a user's Page Layout for a given record, the user will receive an Insufficient Privileges error if attempting to access the ViewAllActivityHistoryPage for that record. This is by design.

The suggested workarounds were to:

  • Use the link as Peter suggested above (which is, of course, unsupported)
  • Have a custom link leading to an Activity Report
  • Use Visualforce for a custom solution

I have started an Idea to have this behaviour changed - see Allow View Activity History Without the Related List Being on the Page Layout

Update

Salesforce has added a knowledge article documenting this behavior.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.