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
Jill HedbergJill Hedberg 

Help with IF statement for a VF email template

Hi,

 

Could you please help me write an IF statement (I think that's what I need?) for my Visualforce email template?

 

I have a VF email template that (among other things) pulls all information from the opportunity contact role related list. What I really would like is for it to just pull the information from one specific role = "Delivery Contact". So that if several roles are specified in the list the others will not show up in my email, and if the role "Delivery Contact" is not specified at all in the opportunity contact role related list  the table is left blank.

 

Is it an IF statement I need, and how would it look?

 

This is my code:

 

<p>
<table border="0" width="560">
<tr >
<th>Role</th><th>Name</th><th>Email</th><th>Phone</th><th>Primary Contact?</th>
</tr>
<apex:repeat var="ContactRole" value="{!relatedTo.OpportunityContactRoles}">
<tr>
<td>{!ContactRole.Role}</td>
<td>{!ContactRole.Contact.Name}</td>
<td>{!ContactRole.Contact.Email}</td>
<td>{!ContactRole.Contact.Phone}</td>
<td>{!ContactRole.IsPrimary}</td>
</tr>
</apex:repeat>
</table>
</p>

 

 Thanks in advance!

Best Answer chosen by Admin (Salesforce Developers) 
Mukul MudgalMukul Mudgal

Try something like this

 

<apex:repeat var="ContactRole" value="{!relatedTo.OpportunityContactRoles}">
<apex:outputPanel rendered="{!ContactRole.Role ='Delivery Contact'}">
<tr>
<td>{!ContactRole.Role}</td>
<td>{!ContactRole.Contact.Name}</td>
<td>{!ContactRole.Contact.Email}</td>
<td>{!ContactRole.Contact.Phone}</td>
<td>{!ContactRole.IsPrimary}</td>
</tr>
</apex:outputPanel>
</apex:repeat>

All Answers

Mukul MudgalMukul Mudgal

Try something like this

 

<apex:repeat var="ContactRole" value="{!relatedTo.OpportunityContactRoles}">
<apex:outputPanel rendered="{!ContactRole.Role ='Delivery Contact'}">
<tr>
<td>{!ContactRole.Role}</td>
<td>{!ContactRole.Contact.Name}</td>
<td>{!ContactRole.Contact.Email}</td>
<td>{!ContactRole.Contact.Phone}</td>
<td>{!ContactRole.IsPrimary}</td>
</tr>
</apex:outputPanel>
</apex:repeat>

This was selected as the best answer
Jill HedbergJill Hedberg

Works perfectly! Thank you so much!