+ Start a Discussion
b.gonzalezb.gonzalez 

Error: Unknown property 'core.email.template.EmailTemplateComponentController

When saving my visualforce page email template, I recieve the following Error: Unknown property 'core.email.template.EmailTemplateComponentController.CampaignMember'.

Visualforce Email Template
<messaging:emailTemplate subject="PDR Generated Prospect is Available for Follow-Up PDR: NA - South Central Seek List" recipientType="User" relatedToType="CampaignMember">
<messaging:htmlEmailBody >
     <html>
        <body>
         <STYLE type="text/css">
               TH {font-size: 14px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center }
               TD  {font-size: 14px; font-face: verdana }
               TABLE {border: solid #CCCCCC; border-width: 1}
               TR {border: solid #CCCCCC; border-width: 1}
         </STYLE>
                  <font face="arial" size="3"></font>
        <p>Dear Salesforce User,</p>
        <p>New PDR Generated prospect(s)have been assigned to a your <b>PDR Generated</b> seek list and is now available for follow up in the following <b>Power Dialer</b> seek list:</p>
        <p><b>PDR Generated (NA - South Central)</b></p>
        <p>To launch the seek list, please click on the following link: <apex:outputLink value="https://na6.salesforce.com/{!CampaignMember.id}">{!CampaignMember.Name}</apex:outputLink></p>
<table border="1"></table>
<tr></tr>
<table border="0" >
                 <tr >
                     <th>Prospect First Name</th><th>Prospect Last Name</th><th> Title </th><th> Phone </th><th> Email </th><th> State </th><th> Country </th><th>Company Name</th><th> Marketing Source</th>
                 </tr>
    <apex:repeat var="cm" value="{!relatedTo.CampaignMember}">
       <tr>
           <td>{!cm.FirstName}</td>
           <td>{!cm.LastName}</td>
           <td>{!cm.Title}</td>
           <td>{!cm.Phone}</td>
           <td>{!cm.Email}</td>
           <td>{!cm.State}</td>
           <td>{!cm.Country}</td>
           <td>{!cm.CompanyOrAccount}</td>
           <td>{!cm.Campaign}</td>
           </tr>
    </apex:repeat>               
       </table>
        </body>
    </html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

Best Answer chosen by b.gonzalez
Blake TanonBlake Tanon
no problem, glad it works!

All Answers

Blake TanonBlake Tanon
This, you can't iterate over your RelatedToType.  You're trying to tell SFDC to get the campaignMember.campaignMember in your repeat tag.

<apex:repeat var="cm" value="{!relatedTo.CampaignMember}">
       <tr>
           <td>{!cm.FirstName}</td>
           <td>{!cm.LastName}</td>
           <td>{!cm.Title}</td>
           <td>{!cm.Phone}</td>
           <td>{!cm.Email}</td>
           <td>{!cm.State}</td>
           <td>{!cm.Country}</td>
           <td>{!cm.CompanyOrAccount}</td>
           <td>{!cm.Campaign}</td>
           </tr>
    </apex:repeat>
Blake TanonBlake Tanon
You need to change your relatedToType to Campaign,then change the link you have in the apex:outputlink to relatedTo.id instead of campaignMember.

Make the repeat {!relatedTo.campaignMembers} should work.
b.gonzalezb.gonzalez
I made the changes you suggested. 

Shote the repeat be: <apex:repeat value="{!relatedTo.CampaignMember}">?

I am still recieving the same error. 

See changes in bold. 


<messaging:emailTemplate subject="PDR Generated Prospect is Available for Follow-Up PDR: NA - South Central Seek List" recipientType="User" relatedToType="Campaign">
<messaging:htmlEmailBody >
     <html>
        <body>
         <STYLE type="text/css">
               TH {font-size: 14px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center }
               TD  {font-size: 14px; font-face: verdana }
               TABLE {border: solid #CCCCCC; border-width: 1}
               TR {border: solid #CCCCCC; border-width: 1}
         </STYLE>
                  <font face="arial" size="3"></font>
        <p>Dear Salesforce User,</p>
        <p>New PDR Generated prospect(s)have been assigned to a your <b>PDR Generated</b> seek list and is now available for follow up in the following <b>Power Dialer</b> seek list:</p>
        <p><b>PDR Generated (NA - South Central)</b></p>
        <p>To launch the seek list, please click on the following link: <apex:outputLink value="https://na6.salesforce.com/{!relatedTo.id}">{!relatedTo.Name}</apex:outputLink></p>
<table border="1"></table>
<tr></tr>
<table border="0" >
                 <tr >
                     <th>Prospect First Name</th><th>Prospect Last Name</th><th> Title </th><th> Phone </th><th> Email </th><th> State </th><th> Country </th><th>Company Name</th><th> Marketing Source</th>
                 </tr>
    <apex:repeat value="{!relatedTo.CampaignMember}">
       <tr>
           <td>{!relatedTo.FirstName}</td>
           <td>{!relatedTo.LastName}</td>
           <td>{!relatedTo.Title}</td>
           <td>{!relatedTo.Phone}</td>
           <td>{!relatedTo.Email}</td>
           <td>{!relatedTo.State}</td>
           <td>{!relatedTo.Country}</td>
           <td>{!relatedTo.CompanyOrAccount}</td>
           <td>{!relatedTo.Campaign}</td>

           </tr>
    </apex:repeat>               
       </table>
        </body>
    </html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
Blake TanonBlake Tanon
CampaignMembers. With an s at the end
Blake TanonBlake Tanon
Sorry you also need the var in your repeat set and that will be how you call the campaign member fields not relatedTo.
b.gonzalezb.gonzalez
Okay. I did that. I tried entering apex repeat 3 different ways but I keep getting the same error.

1) <apex:repeat var = "cm" value="{!relatedTo.CampaignMembers}">
       <tr>
           <td>{!cm.relatedTo.FirstName}</td>
           <td>{!cm.relatedTo.LastName}</td>
           <td>{!cm.relatedTo.Title}</td>
           <td>{!cm.relatedTo.Phone}</td>
           <td>{!cm.relatedTo.Email}</td>
           <td>{!cm.relatedTo.State}</td>
           <td>{!cm.relatedTo.Country}</td>
           <td>{!cm.relatedTo.CompanyOrAccount}</td>
           <td>{!cm.relatedTo.Campaign}</td>
           </tr>
    </apex:repeat>

2) <apex:repeat var = "cm" value="{!relatedTo.CampaignMembers}">
     <tr>
           <td>{!cm.FirstName}</td>
           <td>{!cm.LastName}</td>
           <td>{!cm.Title}</td>
           <td>{!cm.Phone}</td>
           <td>{!cm.Email}</td>
           <td>{!cm.State}</td>
           <td>{!cm.Country}</td>
           <td>{!cm.CompanyOrAccount}</td>
           <td>{!cm.Campaign}</td>
           </tr>
    </apex:repeat>

3)<apex:repeat var = "cm" value="{!relatedTo.CampaignMembers}">
<tr>          
<td>{!relatedTo.FirstName}</td>
           <td>{!relatedTo.LastName}</td>
           <td>{!relatedTo.Title}</td>
           <td>{!relatedTo.Phone}</td>
           <td>{!relatedTo.Email}</td>
           <td>{!relatedTo.State}</td>
           <td>{!relatedTo.Country}</td>
           <td>{!relatedTo.CompanyOrAccount}</td>
           <td>{!relatedTo.Campaign}</td>
           </tr>
March 25, 2014 · Like0 · Dislike0 · FlagBest Answer
Blake TanonBlake Tanon
The second will work, but you're going to get an error because those fields don't exist on campaignMember.  So you'll need to replace them with something like this, to tell if it's a lead or contact.

{!IF(cm.contactId != null,cm.contact.FirstName,cm.lead.firstname)}







<messaging:emailTemplate subject="PDR Generated Prospect is Available for Follow-Up PDR: NA - South Central Seek List" recipientType="User" relatedToType="Campaign">
<messaging:htmlEmailBody >
     <html>
        <body>
         <STYLE type="text/css">
               TH {font-size: 14px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center }
               TD  {font-size: 14px; font-face: verdana }
               TABLE {border: solid #CCCCCC; border-width: 1}
               TR {border: solid #CCCCCC; border-width: 1}
         </STYLE>
                  <font face="arial" size="3"></font>
        <p>Dear Salesforce User,</p>
        <p>New PDR Generated prospect(s)have been assigned to a your <b>PDR Generated</b> seek list and is now available for follow up in the following <b>Power Dialer</b> seek list:</p>
        <p><b>PDR Generated (NA - South Central)</b></p>
        <p>To launch the seek list, please click on the following link: <apex:outputLink value="https://na6.salesforce.com/{!relatedTo.id}">{!relatedTo.Name}</apex:outputLink></p>
<table border="1"></table>
<tr></tr>
<table border="0" >
                 <tr >
                     <th>Prospect First Name</th><th>Prospect Last Name</th><th> Title </th><th> Phone </th><th> Email </th><th> State </th><th> Country </th><th>Company Name</th><th> Marketing Source</th>
                 </tr>
    <apex:repeat var = "cm" value="{!relatedTo.CampaignMembers}">
     <tr>
           <td>{!IF(cm.contactId != null,cm.contact.FirstName,cm.lead.firstname)}</td>
           <td>{!cm.LastName}</td>
           <td>{!cm.Title}</td>
           <td>{!cm.Phone}</td>
           <td>{!cm.Email}</td>
           <td>{!cm.State}</td>
           <td>{!cm.Country}</td>
           <td>{!cm.CompanyOrAccount}</td>
           <td>{!cm.Campaign}</td>
           </tr>
    </apex:repeat>       
       </table>
        </body>
    </html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

b.gonzalezb.gonzalez
Thanks that worked. 

The final version of that section  is:

<apex:repeat var="cm" value="{!relatedTo.CampaignMembers}">
     <tr>
           <td>{!IF(cm.contactId != null,cm.contact.FirstName,cm.lead.firstname)}</td>
           <td>{!IF(cm.contactId != null,cm.contact.LastName,cm.lead.lastname)}</td>
           <td>{!IF(cm.contactId != null,cm.contact.Title,cm.lead.Title)}</td>
           <td>{!IF(cm.contactId != null,cm.contact.Phone,cm.lead.Phone)}</td>
           <td>{!IF(cm.contactId != null,cm.contact.Email,cm.lead.Email)}</td>
           <td>{!IF(cm.contactId != null,cm.contact.MailingState,cm.lead.State)}</td>
           <td>{!IF(cm.contactId != null,cm.contact.MailingCountry,cm.lead.Country)}</td>
           <td>{!IF(cm.contactId != null,cm.contact.Account,cm.lead.Company)}</td>
           <td>{!cm.Campaign}</td>
           </tr>
    </apex:repeat>
Blake TanonBlake Tanon
no problem, glad it works!
This was selected as the best answer