0

So, a while back I wrote a custom vf page for our tasks detail view. We wanted to add some way to track task edits, which is the <c:TaskHistory />. Now thats not the problem - just the starting point.

<apex:page standardController="Task" >
    <apex:detail subject="{!Task.Id}" relatedList="false" inlineEdit="false" />
    <apex:relatedList list="Attachments"/>
    <c:TaskHistory Id_param="{!Task.Id}" />
</apex:page>

Today, this page stopped working. Trying to load it (as an admin) gives me this error:

Data Not Available

The data you were trying to access could not be found. It may be due to another user deleting the data or a system error. If you know the data is not deleted but cannot access it, please look at our support page.

Commenting out everything but the detail still gives the same message.

The user who reported this was the owner of the account, as well as the owner of the task, and got the same message when loading the page.

Trying to query the record from the dev console returns 0 records - both for the specific task (by id) as well as all tasks under that account.

I did some research and tried the following things:

  • Sharing for Activity is set to "Controlled by Parent"
  • Sharing for Accounts is set to "Public Read/Write"
  • Permission set applied to user gives them permissions for the page, the edit class, the edit page, etc.
  • Checked Task access in permission set - wasn't able to edit read/write but all custom fields are available to the user.
  • Removing all content from the page leaves me with a blank page and no error - trying to use the apex:detail seems to cause the error
  • Using a different task id - under an account which I'm not the owner, and not the owner of the task, shows the task details.

However, removing the visualforce page entirely, and using the standard view instead, works totally fine & lets users access the record & edit it.

Digging a little deeper, it seems like tasks over a year are archived, which makes them inaccessible in the developer console/apex. Which is a huge problem, because that makes each task a ticking time bomb. Eventually it'll archive itself & then anyone who tries to view the details of that task will be greeted instead by an error message.

As always, theres an idea with a comment from the product team, 3 years ago.

How can I modify my pages to allow access to the record, without accessing the record, and without changing the page to not use the standard controller (since doing so wouldn't let me use the page as an override)?

1 Answer 1

0

Looks like accessing just the controller.getId() & using that Id to query (with ALL ROWS works just fine. I think I was hung up on the getID - since I considered it "accessing" the record.

<apex:page standardController="Task" >
    <apex:detail subject="{!Task.Id}" relatedList="false" inlineEdit="false" />
    <apex:relatedList list="Attachments"/>
    <c:TaskHistory Id_param="{!Task.Id}" />
</apex:page>


public class TaskDetail_ext {

    public Task SomeTask { get; set; }

    public TaskDetail_ext(ApexPages.StandardController controller) {
        SomeTask = [
            SELECT Id, Subject 
            FROM Task 
            WHERE Id = :controller.getId()
            LIMIT 1
            ALL ROWS 
        ];
    }

}

Theres another solution using the id from the url string here:

Controller extension on an archived task

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .