+ Start a Discussion
etessetess 

Error on .getContentAsPDF() ( PDF preview page )

I have a VF Page called "bidPDFPreview" which I'd like to use as a "Preview PDF" page; it has an inline frame of a VF PDF called bidPDF. This all displays properly. I have a button that executes an APEX method to save the bidPDF as a QuoteDocument and redirect to the PDF. However, I am getting the following error upon executing my Save Method:

 

SObject row was retrieved via SOQL without querying the requested field: (fields on my bidPDF page)

 

 

My APEX Class is below, with the problem line of code bolded: (When I comment out that line, the button correctly just brings up the PDF). For simplicity's sake, I removed the code that actually creates the QuoteDocument from the Blob and inserts it since that is not what is causing this issue.

 

public class quoteExtension {

private final Quote qte;

public quoteExtension(ApexPages.StandardController stdController) {
this.qte = (Quote)stdController.getRecord();
}

public PageReference quoteSave(){

PageReference QuotePDFPage = new PageReference('/apex/bidPDF?id='+qte.Id);
QuotePDFPage.setRedirect(true);
Blob QuotePDFBlob = QuotePDFPage.getContentAsPDF();
return QuotePDFPage;

}

}

 

Also note the bidPDF page is set to display as a PDF, and that Blob definition fails using both .getContentAsPDF() and .getContent()

 

When I add hidden fields onto my bidPDFPreview page, it seems to help (it starts showing errors for different fields), but it seems excessive to duplicate and hide all the code on my bidPDF page into the preview to make this work.

Duncan_IdahoDuncan_Idaho

I would try taking out the setRedirect line. "setRedirect = true" clears the view state and could be removing the values for those fields from memory.

etessetess

I receive the same exact error with that commented out.

 

For some reason, on the Blob definition where I .getContent() from bidPDF, it seems to want the fields that are on bidPDF on the bidPDFPreview page. I don't really understand why.

Duncan_IdahoDuncan_Idaho

would you mind to post the code for the pages?

etessetess

Ah - I appreciate the help, but I actually just include the VP Page bidPDF in my bidPDFPreview page as Hidden, and that seemed to do the trick. Very strange though.