You need to sign in to do that
Don't have an account?
Sanchi9
Display upto 2 decimal places in Visual force email template
Hi,
I have written a code for an email template using visual force where I want to display the Margin percent field upto two decimal places. Currently I am getting the table in this format:
Here is the code:
<messaging:emailTemplate recipientType="User"
subject="Quote Appoval for {!relatedTo.name}"
relatedToType="Quote">
<messaging:htmlEmailBody >
<html>
<body>
<p>Dear {!recipient.name},</p>
<p>Please find below details related to Quote - {!relatedTo.Name}.<br/>
Customer - {!relatedTo.Account.Name}<br/>
Customer Type - {!relatedTo.Account.Type}<br/>
Total amount - ${!relatedTo.New_Total_Price__c}<br/>
Margin Percent- {!relatedTo.Margin_Percent__c}%<br/>
Approval reason : Total discount on quote exceeds {!relatedTo.Total_Discount__c} %.<br/>
</p>
<br/>
<p>
Product Information:
<table border="2" >
<tr>
<th>Product</th>
<th>Product quantity</th>
<th>Total Price</th>
<th>Margin Percent</th>
<th>Discount</th>
<th>Discount Reason</th>
</tr>
<apex:repeat var="cx" value="{!relatedTo.QuoteLineItems}">
<tr>
<td>{!cx.Product2.Name}</td>
<td>{!cx.Quantity}</td>
<td>${!cx.Total_Price__c}</td>
<td>${!cx.Margin_Percent__c}</td>
</tr>
</apex:repeat>
</table>
</p>
<br/>
</body>
</html>
I have written a code for an email template using visual force where I want to display the Margin percent field upto two decimal places. Currently I am getting the table in this format:
Here is the code:
<messaging:emailTemplate recipientType="User"
subject="Quote Appoval for {!relatedTo.name}"
relatedToType="Quote">
<messaging:htmlEmailBody >
<html>
<body>
<p>Dear {!recipient.name},</p>
<p>Please find below details related to Quote - {!relatedTo.Name}.<br/>
Customer - {!relatedTo.Account.Name}<br/>
Customer Type - {!relatedTo.Account.Type}<br/>
Total amount - ${!relatedTo.New_Total_Price__c}<br/>
Margin Percent- {!relatedTo.Margin_Percent__c}%<br/>
Approval reason : Total discount on quote exceeds {!relatedTo.Total_Discount__c} %.<br/>
</p>
<br/>
<p>
Product Information:
<table border="2" >
<tr>
<th>Product</th>
<th>Product quantity</th>
<th>Total Price</th>
<th>Margin Percent</th>
<th>Discount</th>
<th>Discount Reason</th>
</tr>
<apex:repeat var="cx" value="{!relatedTo.QuoteLineItems}">
<tr>
<td>{!cx.Product2.Name}</td>
<td>{!cx.Quantity}</td>
<td>${!cx.Total_Price__c}</td>
<td>${!cx.Margin_Percent__c}</td>
</tr>
</apex:repeat>
</table>
</p>
<br/>
</body>
</html>
you can display up to 2 decimal places please use below code
If you find your Solution then mark this as the best answer.
Thank you!
Regards,
Suraj Tripathi