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
RemediosRemedios 

Mail Merge fields error in VF page

I have setup a custom object invoice and am trying to insert mail merge fields in the visual force page which is called when users click on Print Preview custom button. However when I enter mail merge fields from my custom object I am getting errors that fields do not exist. Here's my code thus far:

 

the error is: Error: Field $Invoice__c.Invoice_type does not exist. Check spelling.

 

<apex:page standardController="Invoice__c" standardStylesheets="true" showHeader="false" sidebar="false" tabStyle="Invoice__c">         <table width="110%" border="0" cellpadding="0" cellspacing="0"> 
   <tr><td><apex:image url="{!$Resource.ceridianLogo}" width="387" height="96" /></td> 
    <td align="right"><a href="javascript&colon;window.print();">Print</a></td></tr> 
    </table>     <apex:outputLabel value="Invoice number" for="InvoiceNumber"/>    <apex:outputText id="InvoiceNumber2" value="{!$Invoice__c.Invoice_Number__c}"/>    <apex:pageBlock title="invoice description">    <b>This is an invoice for <i>{!$User.FirstName}</i>.</b>    

</apex:pageBlock> </apex:page>

 

 

Best Answer chosen by Admin (Salesforce Developers) 
RemediosRemedios

My button was misconfigured that's why it did not pick up the record ID

All Answers

aballardaballard

The $ in the name is incorrect.

RemediosRemedios

If I don't use the $ it doesn't bring me the value (the number of the invoice) it only show the name of the field.

aballardaballard

$ is not part of the name, except for some special system objects like $User.   The syntax to include the field from your custom object should be

  {!Invoice__c.Invoice_Number__c}

 

 



RemediosRemedios

But as I said above if use this syntax I have only "Invoice Number" displayed and the actual number (which is autonumber) doesn't show up

aballardaballard

That's coming, correclly, from the <apex:outputLabel> .  Which shows it is correctly accessing the field.   If you are not seeing a number, there problably isn't a value in the field.  Autonumber won't have a value until the record has been saved.

RemediosRemedios

it's not working with any of the fields from my custom object and there are values. It displays the field name but not the value. Any idea? IS there anything else I need to configure for my cuctom object to be used in VF? I am new to this and this so I might not have setup something properly.

aballardaballard

Sounds like you don't have an object to diisplay.  How are you loading the page?  You need to specify the id of an existing object in the query parameter when you load the page. 

RemediosRemedios

The code pasted above is all I have so far. It's activated when a user clicks on a custom button. the page displays the user.firstname and my logo but nothing from the custom object invoice__c - I mean no values, just field labels

 

Also - I am doing this in my Sandbox - if that matters

RemediosRemedios

My button was misconfigured that's why it did not pick up the record ID

This was selected as the best answer