I have a visualforce page (a letter menu) that on the click of a button (downloads a PDF and saves a letter to the record):
<apex:commandButton action="{!saveLetter}" value="Download Letter"/>
Runs some apex which includes a controller extension with:
pageReference pdf = Page.visualforce_detail_page;
system.debug(pdf);
pdf.getParameters().put('id',wo.ID);
return pdf;
This then displays the "visualforce_detail_page" that only includes a standard controller. On this page I have some fields like:
<apex:page standardController="WorkOrder" renderAs="PDF" showHeader="false" >
{!workorder.workordernumber}
{!workorder.address_line_1__c}
</apex:page>
If I was to view this page directly from the Case Detail page it works as expected, so does typing in the url manually. However if I try and open the detail visualforce from the 1st one it produces the error:
standard SObject row was retrieved via SOQL without querying the requested field: address_line_1__c
What I don't understand is why it works from the detail page, as I would expect, but it doesn't work when called from the visualforce page and the ID passed with it? The only field I have been able to get to work is "WorkOrderNumber"...
P.S I was hoping the "letters" whilst all called from the "letter menu" don't need custom apex. I wanted to use the standard controller, to save a bit of time and work tbh.