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
laurenklaurenk 

VisualForce Email Template Error

I'm trying to use VisualForce for the first time and since I have some HTML knowledge thought the email template might be the easiest place for me to start - I've got it complete but unfortunately keep getting errors upon save, here is what I have so far:

 

<messaging:emailTemplate recipientType="User"
relatedToType="Opportunity"
subject="New Bookings{!relatedTo.Account.Name}"
replyTo="new_bookings@spiceworks.com">
<messaging:htmlEmailBody >
<b>Customer Name:</b> {!relatedTo.Account.Name} <br/>
<b>Date of Booking:</b> {!Opportunity.CloseDate} <br/>
<b>Total Committed Booking Amount:</b> {!Opportunity.Amount} <br/>
<b>Total At Risk Booking Amount:</b>{!OpptyLineItem__c.At_Risk_Bookings_Amount__c} <br/>
<b>Grand Total Booking:</b> {!Opportunity.Amount} <br/> <br/>

<table width="100%"
     style="border-style: solid; border-width: 1px; border-color: #00000">
<u><tr><th>Timeframe</th>
<th>Product</th>
<th>Description</th>
<th>Geo</th>
<th>Volume (K)</th>
<th>CPM/CPL/Cost Per Month</th>
<th>Value</th>
</tr></u>
<tr>
<!--{!relatedTo.OpptyLineItem__c.Name}-->
<td>{!relatedTo.OpptyLineItem__c.StartDate__c} - {!relatedTo.OpptyLineItem__c.EndDate__c} </td>
<td>{!relatedTo.OpptyLineItem__c.ProductId__c}</td>
<td>{!relatedTo.OpptyLineItem__c.Description__c}</td>
<td>{!relatedTo.OpptyLineItem__c.Region__c}</td>
<td>{!relatedTo.OpptyLineItem__c.Quantity__c}</td>
<td>{!relatedTo.OpptyLineItem__c.ListPrice__c}</td>
<td>{!relatedTo.OpptyLineItem__c.Total__c}</td>
</tr>
</table><br/><br/>

<b>Total:</b> {!Opportunity.Amount} <br/>
<b>Salesforce IO Number:</b> {!Opportunity.IONumber__c} <br/>
<b>Link to IO:</b> {!Opportunity.IO_Customer_URL__c} <br/>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

 

 

I keep getting an error listed as: Unknown property 'core.email.template.EmailTemplateComponentController.Opportunity'

 

I suspect this is because I'm trying to call the related Account data and Opportunity Line Item data into the template but don't understand why it won't let me do that since both have direct relationships with the Opportunity object.

 

Help!

JoyDJoyD

Ran across your post as I'm searching for something else, assume you figured it out by now, but if not, it looks like you set it up for User and then Opportunity, which of course don't relate, so that's probably what's going on.  Change User to Contact and I believe then you can either choose the related to as Opportunity, but if not, choose Account and you can traverse down to Opps fairly easily from there.