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
AdammcUKAdammcUK 

using IF in PDF quote template

I need to perform an IF in a visualforce PDF template so I can break the quote into sections e.g. Product, Services, Ongoing costs etc ...

 

Any ideas how I can do this? 

 

<apex:repeat var="opp" value="{!relatedTo.OpportunityLineItems}">

<!-- IF (opp.Qty==999) --> <tr> <td colspan="4"><h2>{!opp.Description}</h2></td> </tr> 

<!-- ELSE --> 

<tr> <td>{!opp.PriceBookEntry.Name}<br>{!opp.Description}</td> <td>{!ROUND(opp.Quantity,1)}</td> <td align="right">{!ROUND(opp.UnitPrice*1.00,2)}</td> <td align="right">{!ROUND(opp.TotalPrice*1.00,2)}</td> 

</tr>  

<!-- END IF --> 

</apex:repeat>  

Best Answer chosen by Admin (Salesforce Developers) 
SteveAnderson41SteveAnderson41

Wrap your td elements in apex:outputPanel components and set the rendered attribute on the output panel to your conditional.  Like this ugly example:

 

 

<apex:page standardController="Account" recordSetVar="accounts" tabstyle="account" sidebar="false"> <table> <apex:repeat value="{!accounts}" var="a"> <apex:repeat value="{!a.Contacts}" var="c"> <tr> <apex:outputPanel rendered="{!BEGINS(c.Name, 'B')}"> <td> Contact name starts with a B, it's {!c.name} </td> </apex:outputPanel> <apex:outputPanel rendered="{!NOT(BEGINS(c.Name, 'B'))}"> <td> Contact name doesn't start with a B, it's {!c.Name} </td> </apex:outputPanel> </tr> </apex:repeat> </apex:repeat> </table> </apex:page>

 

If the contact name on the account starts with a B, the first td is displayed.  If the contact name doesn't start with a B, the second td is displayed.