+ Start a Discussion
sfdcrajsfdcraj 

"Content cannot be displayed: Unable to retrieve object" error message

Hi,

I have an inline visualforce page on Event pagelayout. This VF page queries data from custom object and display data. 

I have loaded data into the event object.  the event records which have due date older than 365 days automatically went into archive according salesforce feature.(IsArchived changed to true).

Now, for all these archived events the inline  visualforce page is displaying an error instead of data. The Error message is
"Content cannot be displayed: Unable to retrieve object"

But, the non-archived current events are not having any problem. The visualforce displays data properly.

Do anyone have insights on this??


Regards,
raj
Best Answer chosen by Sonam (Salesforce Developers) 
sfdcrajsfdcraj
Hi Sonam,

Thank you so much for the heads up:-)

There is no query on my visualforce page which is querying archived events but your post did help me though.

I was using

EventAssc=(Event)controller.getRecord();                 

to get the current record and then EventAssc.id to get the id of the current event. I tried your approach of taking the ID from URL

(Id) System.currentPageReference().getParameters().get('id');

and it worked.......the standard controller method was not able to pull the archived Event record

Appreciate your help!!!!!

Regards,
raj

All Answers

Sonam_SFDCSonam_SFDC
Hi Raj,

Is the visualforce page on Events pagelayout trying to fetch data from other archived events? if yes, please update the SOQL query on the VF page with ALL ROWS tag as shown in below sample code snippet for Task:

public with sharing class myCustomTaskQuery {
   
    Task myTask;
   
    public myCustomTaskQuery(ApexPages.StandardController con) {       
        Id myTaskId = (Id) System.currentPageReference().getParameters().get('id');   
        myTask = [SELECT Id, Subject FROM Task WHERE IsDeleted = false AND Id = :myTaskId LIMIT 1 ALL ROWS];
    }
   
    public String getTaskSubject() {
        return myTask.Subject;
    }   
}
sfdcrajsfdcraj
Hi Sonam,

Thank you so much for the heads up:-)

There is no query on my visualforce page which is querying archived events but your post did help me though.

I was using

EventAssc=(Event)controller.getRecord();                 

to get the current record and then EventAssc.id to get the id of the current event. I tried your approach of taking the ID from URL

(Id) System.currentPageReference().getParameters().get('id');

and it worked.......the standard controller method was not able to pull the archived Event record

Appreciate your help!!!!!

Regards,
raj
This was selected as the best answer
CasselJCasselJ
How wer eyou able to test your solution?