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
Scott WalkerScott Walker 

Visualforce email template - fields from another related object

HI all 

So I made my first ever visualforce coded email which is very exciting for me.  I was wondering if it was possible to add fields from another object to show what I need this to.  If so how do I go about doing that do you think?  You will see that I have put in ????? where I would like to add the two other object fields (found at the bottom of the code).  They are both dfrom an object called Purchase_Request_Rollup__c and the fields are Textbook_Roll__c and APP_Textbook_Roll__c

Any help much appreciated
 
<messaging:emailTemplate subject="test table" recipientType="Contact" relatedToType="Purchase_Request_Form__c">
<messaging:htmlEmailBody >
<html>
<head>
<table width="581" border="1">
    <tr>
      <th width="61" scope="col">Item</th>
      <th width="85" scope="col">Item Description</th>
      <th width="68" scope="col">Price per Item</th>
      <th width="40" scope="col">Qty</th>
      <th width="102" scope="col">Total Price</th>
    </tr>
    <tr>
      <th scope="row">Item 1</th>
      <td>{!relatedTo.Description_of_Item_1__c}</td>
      <td>{!relatedTo.Amount_of_Item_1__c}</td>
      <td>{!relatedTo.Quantity_of_Item_1__c}</td>
      <td>{!relatedTo.Price_Per_Unit_1__c}</td>
    </tr>
    <tr>
      <th scope="row">Item 2</th>
      <td>{!relatedTo.Description_of_Item_2__c}</td>
      <td>{!relatedTo.Amount_of_Item_2__c}</td>
      <td>{!relatedTo.Quantity_of_Item_2__c}</td>
      <td>{!relatedTo.Price_Per_Unit_2__c}</td>
    </tr>
    <tr>
      <th scope="row">Item 3</th>
      <td>{!relatedTo.Description_of_Item_3__c}</td>
      <td>{!relatedTo.Amount_of_Item_3__c}</td>
      <td>{!relatedTo.Quantity_of_Item_3__c}</td>
      <td>{!relatedTo.Price_Per_Unit_3__c}</td>
    </tr>
    <tr>
      <th scope="row">Item 4</th>
     <td>{!relatedTo.Description_of_Item_4__c}</td>
      <td>{!relatedTo.Amount_of_Item_4__c}</td>
      <td>{!relatedTo.Quantity_of_Item_4__c}</td>
      <td>{!relatedTo.Price_Per_Unit_4__c}</td>
    </tr>
    <tr>
      <th scope="row">Item 5</th>
     <td>{!relatedTo.Description_of_Item_5__c}</td>
      <td>{!relatedTo.Amount_of_Item_5__c}</td>
      <td>{!relatedTo.Quantity_of_Item_5__c}</td>
      <td>{!relatedTo.Price_Per_Unit_5__c}</td>
    </tr>
    <tr>
      <th scope="row">Item 6</th>
     <td>{!relatedTo.Description_of_Item_6__c}</td>
      <td>{!relatedTo.Amount_of_Item_6__c}</td>
      <td>{!relatedTo.Quantity_of_Item_6__c}</td>
      <td>{!relatedTo.Price_Per_Unit_6__c}</td>
    </tr>
    <tr>
      <th scope="row">Item 7</th>
     <td>{!relatedTo.Description_of_Item_7__c}</td>
      <td>{!relatedTo.Amount_of_Item_7__c}</td>
      <td>{!relatedTo.Quantity_of_Item_7__c}</td>
      <td>{!relatedTo.Price_Per_Unit_7__c}</td>
    </tr>
    <tr>
      <th scope="row">Item 8</th>
     <td>{!relatedTo.Description_of_Item_8__c}</td>
      <td>{!relatedTo.Amount_of_Item_8__c}</td>
      <td>{!relatedTo.Quantity_of_Item_8__c}</td>
      <td>{!relatedTo.Price_Per_Unit_8__c}</td>
    </tr>
    <tr>
      <th scope="row">Item 9</th>
     <td>{!relatedTo.Description_of_Item_9__c}</td>
      <td>{!relatedTo.Amount_of_Item_9__c}</td>
      <td>{!relatedTo.Quantity_of_Item_9__c}</td>
      <td>{!relatedTo.Price_Per_Unit_9__c}</td>
    </tr>
    <tr>
      <th scope="row">Item 10</th>
     <td>{!relatedTo.Description_of_Item_10__c}</td>
      <td>{!relatedTo.Amount_of_Item_10__c}</td>
      <td>{!relatedTo.Quantity_of_Item_10__c}</td>
      <td>{!relatedTo.Price_Per_Unit_10__c}</td>
    </tr>
   </table>
   
   <p> SHIPPING COSTS = {!relatedTo.Shipping_Costs_Office_fills_this_in__c} </p>
   <p> TOTAL ORDER = {!relatedTo.TOTAL__c} </p>
   
   <p> Your Department has already approved ?????? in Textbook purchases with ?????? Actually ordered and paid for.
</head>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>