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
Sanchi9Sanchi9 

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: 
User-added image


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>
Peter KevinPeter Kevin
Suraj Tripathi 47Suraj Tripathi 47
Hi Priya,

you can display up to 2 decimal places please use below code
 
<apex:outputText value="{0, number, 00.00}">
      <apex:param value="{!relatedTo.Amount__c}" />
</apex:outputText>

If you find your Solution then mark this as the best answer.

Thank you!

Regards,
Suraj Tripathi