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
Alex MakkAlex Makk 

Path to Contact object when creating Email Template

Hi all!
I have an email template and trying to post First and Last names of contacts related to account that are used in custom object.

Here is code:
<apex:repeat value="{!relatedTo.Account1__r.Account_Manager__r.Contact}" var="con">
     <tr>
<td>{!con.FirstName}</td> 
 </tr>
                 </apex:repeat>

For some reason contacts are not showing. Header is relatedToType="Logistic__c" meaning I'm using custom object fields. Account1__r.Account_Manager__r.Contact I got by creating a new formula field and got API address. 

The next step would be to show only contacts that have on their record checkbox field set to true.

I was thinking to use:
 
<apex:repeat value="{!relatedTo.Account1__r.Account_Manager__r.Contact}" var="con">
            <apex:outputPanel rendered="{!AND(con.Email_Notice__c = True)}" layout="none">
                <tr>
                    <td>{!con.FirstName}</td>
                </tr>
            </apex:outputPanel>
 </apex:repeat>

But non of these codes work.. I am new to it.. please advise. Thank you!
Alex MakkAlex Makk
Update. I realized I dont have lookup field to "Contacts" on my custom object.

So new code that still does not work looks like this:
 
<apex:repeat value="{!relatedTo.Contact__r}" var="con">
     <tr>
<td>{!con.FirstName}</td> 
 </tr>
                 </apex:repeat>



 
DixitDixit
Please, the controller side (or extension) where "relatedTo" is declarated.