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
Abhinav GuptaAbhinav Gupta 

Unable to retrieve object - PageReference.getContent()

I am getting this error in a Apex/Visualforce page/controller.


Unable to retrieve object


I am trying to use Page.PageName.getContent() in my controller. This code works well and fails randomly for this error, with same inputs and same state.


Please suggest a fix, tried searching on discussion boards, its mentioned that this error only comes in Apex test cases. But for me its coming in normal visualforce page controllers, and the pain is its coming randomly.


Please help !


I too have seen this error when fetching content from a VF page that renders a pdf.  Sometimes the pdf will appear attached (used it to attach articles in pdf format to emails) and sometimes it wont.


Best as I can tell my code is solid and the failure rate is low but like you said it is random at best.  Sorry I could not be of any more help.




I suggest you open a support case.  


I'm having the same issue on rendering an email task as a PDF.  One thing I've noticed is that it works fine on newer records, but not ones that are from early 2012, so they are archived.  I'm thinking that might be my issue.  The VF page cannot access archived records.