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
Debbie ChrysochouDebbie Chrysochou 

Error: Invalid field AccountNumber for SObject Order

Dear all,

I am a newbie in SFC.
I am trying to create a vf page that will get me the orders with their products. I am trying to include the account name and account number since our customers do get a different account number. 
<messaging:emailTemplate subject="Orders with Products" recipientType="Contact" relatedToType="Order">
<messaging:htmlEmailBody >
                <body style="font-family: 'Sans Serif'">
                    <h2>
                        Order with Products</h2>
                    <hr style="border: solid thin #C017BE"/>
                    <br/>
                    <table sellpadding="5" style="border-collapse: collapse" width="100%">
                        <tr>
                            <td align="right"
                                style="border-right-style: solid; border-reight-width: thin; border-right-color:#C017BE;"
                                width="20%">
                                <i>Name</i>
                            </td>
                            <td width="80%">
                                <b>{!relatedTo.Name}</b>
                            </td>    
                        </tr>
                        <tr>
                            <td align="right"
                                style="border-right-style: solid; border-reight-width: thin; border-right-color:#C017BE;" 
                                width="20%">
                                <i>Account Number</i>
                            </td>
                            <td width="80%">
                                <b>{!relatedTo.AccountNumber}</b>
                            </td>        
                        </tr>
                        <tr>
                            <td align="right"
                                style="border-right-style: solid; border-reight-width: thin; border-right-color:#C017BE;" 
                                width="20%">
                                <i>Wedding Date</i>
                            </td>
                            <td width="80%">
                                <b>{!relatedTo.Wedding_Date__c}</b>
                            </td>        
                        </tr>
                        <tr>
                            <td align="right"
                                style="border-right-style: solid; border-reight-width: thin; border-right-color:#C017BE;" 
                                width="20%">
                                <i>Wedding Time</i>
                            </td>
                            <td width="80%">
                                <b>{!relatedTo.Wedding_Time__c}</b>
                            </td>        
                        </tr>
                        <tr>
                            <td align="right"
                                style="border-right-style: solid; border-reight-width: thin; border-right-color:#C017BE;" 
                                width="20%">
                                <i>Venue</i>
                            </td>
                            <td width="80%">
                                <b>{!relatedTo.Venue__c}</b>

The error that I get is the headline of this post.
I am guessing that I will get the same error for the custom fields that I have created because wedding date/time and venue have been created in the account fields area.
Any idea how to connect these all??
Please help me!!!
Anoop yadavAnoop yadav
Hi,

Use <b>{!relatedTo.Account.AccountNumber}</b>
instead of <b>{!relatedTo.AccountNumber}</b>