+ Start a Discussion
Michelle Arndt 18Michelle Arndt 18 

Visualforce Email template error for custom object

When we create an opportunity we create a certain number of quotes (custom, child record). I would like to be able to send an email to include information from all the quotes created under the opportunity.This is my first visualforce email template. I want to be able to pull I need some help because when I go to save I receive the following error: Unknown property 'core.email.template.EmailTemplateController.Opportunity'
 
<messaging:emailTemplate recipientType="User"
                     relatedToType="Opportunity"
                     subject=" {!Opportunity.Account}, {!Quotes_RFR__c.Current_Carrier__c}, {!Opportunity.Date_Due__c},{!Opportunity.Total_Eligible__c}" >
<messaging:htmlEmailBody >  
    <html>
        <body>
            <STYLE type="text/css">
                TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center } 
                TD  {font-size: 11px; font-face: verdana } 
                TABLE {border: solid #CCCCCC; border-width: 1}
                TR {border: solid #CCCCCC; border-width: 1}
            </STYLE>
            <font face="arial" size="2">
                <table border="0" >
                    <tr > 
                        <th>Quote Number</th><th>Contribution Type</th><th>In Network</th><th>Out of Network</th>
                    </tr>
                    <apex:repeat var="cx" value="{!Quotes_RFR__c}">
                        <tr>
                            <td>{!Quotes_RFR__c.Quote_Name__c} </td>
                            <td>{!Quotes_RFR__c.Contribution_Type__c}</td>
                            <td>{!Quotes_RFR__c.In_NetworkDiag_Prev__c}/ {!NullValue(Quotes_RFR__c.In_Network_Basic__c, "0")}/ {!NullValue(Quotes_RFR__c.In_Network_Major__c, "0")}/ {!NullValue(Quotes_RFR__c.In_Network_Ortho__c, "0")}; {!Quotes_RFR__c.In_Network_Deductible_Ind__c}/ {!Quotes_RFR__c.In_Network_Deductible_Fam__c} Ded; {!Quotes_RFR__c.In_Network_Annual_Max__c} Max; {!NullValue(Quotes_RFR__c.In_Network_Ortho_Max__c, "0")}</td>
                            <td>{!Quotes_RFR__c.Out_Network_Diag_Prev__c}/ {!NullValue(Quotes_RFR__c.Out_Network_Basic__c, "0")}/ {!NullValue(Quotes_RFR__c.Out_Network_Major__c, "0")}/ {!NullValue(Quotes_RFR__c.Out_Network_Ortho__c, "0")}; {!Quotes_RFR__c.Out_Network_Deductible_Ind__c}/ {!Quotes_RFR__c.Out_Network_Deductible_Fam__c} Ded; {!Quotes_RFR__c.Out_Network_Annual_Max__c} Max; {!NullValue(Quotes_RFR__c.Out_Network_Ortho_Max__c, "0")} </td>
                        </tr>
                    </apex:repeat>                 
                </table>
                <p />
            </font>
        </body>
    </html>
</messaging:htmlEmailBody> 
</messaging:emailTemplate >

 
kirubakaran viswanathankirubakaran viswanathan
Hi,

Replace Opportunity in Subject as "!relatedTo." 
Please refer the documentation. https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_email_templates_creating.htm
 
Michelle Arndt 18Michelle Arndt 18
I Updated to the following below and receive this error: Error: Unknown property 'core.email.template.EmailTemplateComponentController.Quotes_RFR__c'
 
<messaging:emailTemplate recipientType="User"
                     relatedToType="Opportunity"
                     subject=" {!relatedTo.Account}, {!Quotes_RFR__c.Current_Carrier__c}, {!relatedTo.Date_Due__c},{!relatedTo.Total_Eligible__c}" >
<messaging:htmlEmailBody >  
    <html>
        <body>
            <STYLE type="text/css">
                TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center } 
                TD  {font-size: 11px; font-face: verdana } 
                TABLE {border: solid #CCCCCC; border-width: 1}
                TR {border: solid #CCCCCC; border-width: 1}
            </STYLE>
            <font face="arial" size="2">
                <table border="0" >
                    <tr > 
                        <th>Quote Number</th><th>Contribution Type</th><th>In Network</th><th>Out of Network</th>
                    </tr>
                    <apex:repeat var="cx" value="{!Quotes_RFR__c}">
                        <tr>
                            <td>{!Quotes_RFR__c.Quote_Name__c} </td>
                            <td>{!Quotes_RFR__c.Contribution_Type__c}</td>
                            <td>{!Quotes_RFR__c.In_NetworkDiag_Prev__c}/ {!NullValue(Quotes_RFR__c.In_Network_Basic__c, "0")}/ {!NullValue(Quotes_RFR__c.In_Network_Major__c, "0")}/ {!NullValue(Quotes_RFR__c.In_Network_Ortho__c, "0")}; {!Quotes_RFR__c.In_Network_Deductible_Ind__c}/ {!Quotes_RFR__c.In_Network_Deductible_Fam__c} Ded; {!Quotes_RFR__c.In_Network_Annual_Max__c} Max; {!NullValue(Quotes_RFR__c.In_Network_Ortho_Max__c, "0")}</td>
                            <td>{!Quotes_RFR__c.Out_Network_Diag_Prev__c}/ {!NullValue(Quotes_RFR__c.Out_Network_Basic__c, "0")}/ {!NullValue(Quotes_RFR__c.Out_Network_Major__c, "0")}/ {!NullValue(Quotes_RFR__c.Out_Network_Ortho__c, "0")}; {!Quotes_RFR__c.Out_Network_Deductible_Ind__c}/ {!Quotes_RFR__c.Out_Network_Deductible_Fam__c} Ded; {!Quotes_RFR__c.Out_Network_Annual_Max__c} Max; {!NullValue(Quotes_RFR__c.Out_Network_Ortho_Max__c, "0")} </td>
                        </tr>
                    </apex:repeat>                 
                </table>
                <p />
            </font>
        </body>
    </html>
</messaging:htmlEmailBody> 
</messaging:emailTemplate >

 
kirubakaran viswanathankirubakaran viswanathan
You have to refer the child object with __r , so in line # 3 ,change {!Quotes_RFR__c.Current_Carrier__c} to {!relatedTo.Quotes_RFR__r.Current_Carrier__c} and in Line # 18 value="{!Quotes_RFR__c}" as value="{!RelatedTo.Quotes_RFR__r}"

and below lines from 20 to 23 change all the Sobject name to variable values like {!cx.Quote_Name__c}

If it resolves, please mark this answer.
Michelle Arndt 18Michelle Arndt 18
I looked at the master detail relationship and it has the Child Relationship Name as: R00N30000001MeIXEA0 so I used that and updated my code to below.  I am now receiving the error: 
Error: Incorrect parameter type for function 'not()'. Expected Boolean, received Text
<messaging:emailTemplate recipientType="User"
                     relatedToType="Opportunity"
                     subject=" {!relatedTo.Account}, {!relatedTo.Date_Due__c},{!relatedTo.Total_Eligible__c}" >
<messaging:htmlEmailBody >  
    <html>
        <body>
            <STYLE type="text/css">
                TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center } 
                TD  {font-size: 11px; font-face: verdana } 
                TABLE {border: solid #CCCCCC; border-width: 1}
                TR {border: solid #CCCCCC; border-width: 1}
            </STYLE>
            <font face="arial" size="2">
                <table border="0" >
                    <tr > 
                        <th>Quote Number</th><th>Contribution Type</th><th>In Network</th><th>Out of Network</th>
                    </tr>
                    <apex:repeat var="cx" value="{!Relatedto.R00N30000001MeIXEA0__r}">
                        <tr>
                            <td>{!cx.Quote_Name__c} </td>
                            <td>{!cx.Contribution_Type__c}</td>
                            <td>{!cx.In_NetworkDiag_Prev__c}/ {!NullValue(!cx.In_Network_Basic__c, "0")}/ {!NullValue(!cx.In_Network_Major__c, "0")}/ {!NullValue(!cx.In_Network_Ortho__c, "0")}; {!cx.In_Network_Deductible_Ind__c}/ {!cx.In_Network_Deductible_Fam__c} Ded; {!cx.In_Network_Annual_Max__c} Max; {!NullValue(!cx.In_Network_Ortho_Max__c, "0")}</td>
                            <td>{!cx.Out_Network_Diag_Prev__c}/ {!NullValue(!cx.Out_Network_Basic__c, "0")}/ {!NullValue(!cx.Out_Network_Major__c, "0")}/ {!NullValue(!cx.Out_Network_Ortho__c, "0")}; {!cx.Out_Network_Deductible_Ind__c}/ {!cx.Out_Network_Deductible_Fam__c} Ded; {!cx.Out_Network_Annual_Max__c} Max; {!NullValue(!cx.Out_Network_Ortho_Max__c, "0")} </td>
                        </tr>
                    </apex:repeat>                 
                </table>
                <p />
            </font>
        </body>
    </html>
</messaging:htmlEmailBody> 
</messaging:emailTemplate >