You need to sign in to do that
Don't have an account?
Curt Griffin 27
Visualforce Email Template Table Displayed if Discounted field = True
I want to display the Discount column in a Table generated via a VF Email Template when the Opportunity's Discounted__c field is True.
When Discounted__c = False, the Discount colunm is not displayed.
I'm OK with duplicating the Table Code for the two conditions Discounted__c True/False.
Here is the VF Code that creates the Table:
Table Code
<thead>
<table class="six">
<tr>
<th class='LeftBorder1' bgcolor="#364E88">Product Code</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Product</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Description</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Qty</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">List Price</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Discount</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Sales Price</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Total Price</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!relatedTo.OpportunityLineItems}" var="line">
<tr style= "page-break-inside: avoid; page-break-after: auto;border-top: 1px solid #666;">
<td class='LeftBorder'>{!line.PricebookEntry.ProductCode}</td>
<td class='RightBorder'>{!line.PricebookEntry.Name}</td>
<td class='RightBorder'><apex:OutputField value="{!line.Product_Description__c}"/></td>
<td class='RightBorder'><apex:OutputField value="{!line.CPQ_Quantity__c}"/></td>
<td class='RightBorder'><apex:OutputField value="{!line.CPQ_Unit_Price__c}"/></td>
<td class='RightBorder'><apex:OutputField value="{!line.CPQ_Discount__c}"/></td>
<td class='RightBorder'><apex:OutputField value="{!line.CPQ_Sales_Price__c}"/></td>
<td class='RightBorder'><apex:OutputField value="{!line.CPQ_Total_Price__c}"/></td>
</apex:repeat>
When Discounted__c = False, the Discount colunm is not displayed.
I'm OK with duplicating the Table Code for the two conditions Discounted__c True/False.
Here is the VF Code that creates the Table:
Table Code
<thead>
<table class="six">
<tr>
<th class='LeftBorder1' bgcolor="#364E88">Product Code</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Product</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Description</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Qty</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">List Price</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Discount</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Sales Price</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Total Price</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!relatedTo.OpportunityLineItems}" var="line">
<tr style= "page-break-inside: avoid; page-break-after: auto;border-top: 1px solid #666;">
<td class='LeftBorder'>{!line.PricebookEntry.ProductCode}</td>
<td class='RightBorder'>{!line.PricebookEntry.Name}</td>
<td class='RightBorder'><apex:OutputField value="{!line.Product_Description__c}"/></td>
<td class='RightBorder'><apex:OutputField value="{!line.CPQ_Quantity__c}"/></td>
<td class='RightBorder'><apex:OutputField value="{!line.CPQ_Unit_Price__c}"/></td>
<td class='RightBorder'><apex:OutputField value="{!line.CPQ_Discount__c}"/></td>
<td class='RightBorder'><apex:OutputField value="{!line.CPQ_Sales_Price__c}"/></td>
<td class='RightBorder'><apex:OutputField value="{!line.CPQ_Total_Price__c}"/></td>
</apex:repeat>
While it is possible to bypass Visualforce's security enforcement by using Apex to acquire the data instead of directly referencing fields, this is not recommended because it does an end-run around the Salesforce security model.
If( Opportunity's Discounted__c is True,
then Table includes the Discount Column and Amount:
<table class="six">
<tr>
<th class='LeftBorder1' bgcolor="#364E88">Product Code</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Product</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Description</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Qty</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">List Price</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Discount</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Sales Price</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Total Price</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!relatedTo.OpportunityLineItems}" var="line">
<tr style= "page-break-inside: avoid; page-break-after: auto;border-top: 1px solid #666;">
<td class='LeftBorder'>{!line.PricebookEntry.ProductCode}</td>
<td class='RightBorder'>{!line.PricebookEntry.Name}</td>
<td class='RightBorder'><apex:OutputField value="{!line.Product_Description__c}"/></td>
<td class='RightBorder'><apex:OutputField value="{!line.CPQ_Quantity__c}"/></td>
<td class='RightBorder'><apex:OutputField value="{!line.CPQ_Unit_Price__c}"/></td>
<td class='RightBorder'><apex:OutputField value="{!line.CPQ_Discount__c}"/></td>
<td class='RightBorder'><apex:OutputField value="{!line.CPQ_Sales_Price__c}"/></td>
<td class='RightBorder'><apex:OutputField value="{!line.CPQ_Total_Price__c}"/></td>
</apex:repeat>
Else Table does NOT include the Discount Column and Amount:
<table class="six">
<tr>
<th class='LeftBorder1' bgcolor="#364E88">Product Code</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Product</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Description</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Qty</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">List Price</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Discount</th><th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Sales Price</th>
<th class='LeftBorder1' bgcolor="#364E88" style="font-size 80%">Total Price</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!relatedTo.OpportunityLineItems}" var="line">
<tr style= "page-break-inside: avoid; page-break-after: auto;border-top: 1px solid #666;">
<td class='LeftBorder'>{!line.PricebookEntry.ProductCode}</td>
<td class='RightBorder'>{!line.PricebookEntry.Name}</td>
<td class='RightBorder'><apex:OutputField value="{!line.Product_Description__c}"/></td>
<td class='RightBorder'><apex:OutputField value="{!line.CPQ_Quantity__c}"/></td>
<td class='RightBorder'><apex:OutputField value="{!line.CPQ_Unit_Price__c}"/></td>
<td class='RightBorder'><apex:OutputField value="{!line.CPQ_Discount__c}"/></td><td class='RightBorder'><apex:OutputField value="{!line.CPQ_Sales_Price__c}"/></td>
<td class='RightBorder'><apex:OutputField value="{!line.CPQ_Total_Price__c}"/></td>
</apex:repeat>