I'm trying to get a "Save PDF" button working on my HTML visualforce page and keep getting the error message above. I've searched everywhere and cannot find a solution and have also been working with someone on the Salesforce developer community and we cannot find a resolution.

Here is my Visualforce code:

<apex:page standardController="Opportunity" applyHtmlTag="true" extensions="Residential_Order_Form" showHeader="false">
<apex:stylesheet value="{!$Resource.Residential_Services_Styles_HTML}"/>

    <meta charset="UTF-8"/></head>
<title>Residential Services Order Form</title>

    <apex:outputPanel rendered="{!$CurrentPage.parameters.hdmen != 'client'}">
        <div id="fixed_bar">
            <div id="fixed_bar_cnt">
                <div class="btn_cont">
                    <apex:form >
                        <apex:outputLink value="https://myorg.my.salesforce.com/apex/Residential_Order_Form_PDF?id={!Opportunity.Id}" styleClass="btnGrey" target="_blank"><apex:outputText value="PRINT" /></apex:outputLink>
                <div class="btn_cont">
                    <apex:form >
                        <apex:commandLink value="Save PDF" action="{!savePDF}" styleClass="btnGrey" />    
                    <apex:form >
                    <apex:outputPanel id="popup">
                            <apex:outputPanel styleClass="customPopup" layout="block" rendered="{!displayPopUp}">
                                <div class="customPopup_content">
                                    <apex:commandButton value="Close" action="{!closePopup}" rerender="popup"/>

Here is the code of the field causing the error when querying the PDF Visualforce page:

 <table class="acceptance">

     <td class="sign">X&nbsp;&nbsp;<apex:image styleClass="sign" url="{!Opportunity.Signature_URL__c}" rendered="{!Opportunity.Signature_URL__c != ''}"/></td>
       <td class="sign">DATE:&nbsp;&nbsp;<apex:outputText value="{0,date,yyyy-MM-dd}"><apex:param value="{!Opportunity.Signature_Date__c}"/></apex:outputText></td> 
     <td class="accept">authorized signature</td>
     <td class="accept">yyyy/mm/dd</td>

Here is my Apex Class extension:

public class Residential_Order_Form {

public Opportunity opp;  
public string emailTo{get; set;}
public string idVal{get;set;}
public string doSave{get;set;}
    // Get lang
public string strOppName;
public boolean displayPopup {get; set;}
public string pop_msg{get; set;}

public Residential_Order_Form (ApexPages.StandardController stdController) {
    opp = (Opportunity)stdController.getRecord();
    idVal = opp.Id;
    doSave = ApexPages.currentPage().getParameters().get('doSave');


public void closePopup() {
    displayPopup = false;

public pageReference savePDF(){

Date dateToday = Date.today();
    String sMonth = String.valueof(dateToday.month());
    String sDay = String.valueof(dateToday.day());
      sMonth = '0' + sMonth;
      sDay = '0' + sDay;
    String sToday = String.valueof(dateToday.year())+ '-' + sMonth +  '-' + sDay ;

  PageReference pagePdf = new PageReference('/apex/Residential_Order_Form_PDF');
      pagePdf.getParameters().put('id', idVal);
      Blob pdfPageBlob;
      pdfPageBlob = pagePdf.getContentAsPDF();

      Attachment a = new Attachment();
      a.Body = pdfPageBlob;
      a.ParentID = idVal;
      a.Name = 'Residential_Order_Form_' + '_' + sToday + '.pdf';
      a.Description = 'Residential_Order_Form_' + sToday;
      insert a;
    pop_msg='Successfully saved';
    displayPopup = true;  

    update opp;
  return new PageReference('/apex/Residential_Order_Form_HTML?id=' + idVal);


The only solution I found that I could even try would be to render it as false, but that doesn't work because I need that field to populate on the PDF form.

  • Since the error you're referring to is being thrown by the PDF, what you really need to look at is the controller code for the PDF itself, not shown here. Does the PDF's controller fail to query the field in question?
    – Charles T
    Commented Oct 23, 2017 at 15:41

1 Answer 1


It means that you have to request this field in a SOQL query. Your visualforce don't know the value of Signature_Date__c because you didn't request it.

In your Controller, you have requested the ID of the opporunity, but not this particular field.

myopp = [SELECT Id, Signature_Date__c FROM Opportunity WHERE id = :opp.Id LIMIT 1];

From here, you will be able to get this field on your Visuaforce page.

Or you can add a method like that :

public DateTime getSignatureDate() { 
    return ([SELECT Id, Signature_Date__c FROM Opportunity WHERE id = :opp.Id LIMIT 1].Signature_Date__c);

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