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
Kwalla25Kwalla25 

VF email template with Standard and Custom Object

I am trying to create a VF email template that will populate with info from both Opportunity (the standard object) and Service_Plans__c (a related custom object), but I can't quite seem to figure it out.  I've read through several similair threads and am just not getting how this is supposed to be done.

 

The actual code I'm trying to use (which I'm sure is all mixed up since I've been toying with it) is below. 

 

Basically:  I want to be able to reference the name of the Opportunity and the Service_Contract_End_Date__c that's part of the custom object. 

<messaging:emailTemplate subject="Notification - Service Plan for {!relatedTo.Name} expires on {!Service_Plans__r.Service_Plan_End_Date__c}" recipientType="User" relatedToType="Opportunity">
<messaging:htmlEmailBody >
    <html>
        <style type="text/css"> 
            body, table {
                font-family: "Arial";
                font-size: 12px;
            }       
        </style>
    
        <body>

            <p>{!recipient.Name},</p>
            
            <p>
                The Serice Plan for {!RelatedTo.Opportunity.Name} expires on {!relatedTo.Service_Plan_End_Date__c}.<br />
 
            </p>

            <p>
                You can access the Opportunity in Salesforce.com to view additional information by clicking the link below:<br />
                <a href="https://na2.salesforce.com/{!relatedTo}">https://na2.salesforce.com/{!relatedTo}</a>
            </p>

        </body>
    </html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

 

 Thanks,

 

Keith