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

how to convert currency field and to display with $ in visualforce

My code was this its an emailtemplate. I want to display and convert currency to usd by displaying $. Amount displaying their were correct but i want to display currency symbols in the below code.

<messaging:emailTemplate recipientType="Contact"
    subject="Productline Items for Opportunity: {!}"
    replyTo="" >
<messaging:htmlEmailBody >       
         <STYLE type="text/css">
               TH {font-size: 11px; font-face: arial;background: #CCCCCC; border-width: 1;  text-align: center }
               TD  {font-size: 11px; font-face: verdana }
               TABLE {border: solid #CCCCCC; border-width: 1}
               TR {border: solid #CCCCCC; border-width: 1}
                  <font face="arial" size="2">
        <p>Dear {!},</p>
        <p>Below is a list of products related to the Opportunity:<b> {!}</b>.</p>
        <br/>Account: <i> {!}  </i> 
        <br/>Opportunity Owner: {!}
        <br/>Opportunity Amount: {!relatedTo.Amount}
        <br/>Opportunity Close Date: {!relatedTo.CloseDate} 
       <table border="0" >
                 <tr >
                     <th>Action</th><th>Product Name</th><th>Product Family</th><th>Quantity</th><th>Unit Price</th><th>Total Price</th>
    <apex:repeat var="opp" value="{!relatedTo.OpportunityLineItems}">
           <td><a href="{!}">View</a> | 
           <a href="{!}/e">Edit</a></td>
       <p />
<messaging:plainTextEmailBody >
Dear {!},

Below is a list of products related to the Opportunity: {!}

Account: {!}
Opportunity Owner: {!}
Opportunity Amount: {!(relatedTo.Amount)}
Opportunity Close Date: {!relatedTo.CloseDate} 

[ Product Name ] - [ Product Family ] - [ Quantity ] - [ Units ] - [ Total Price ]

<apex:repeat var="opp" value="{!relatedTo.OpportunityLineItems}">
[ {!} ] - [ {!opp.Product_Family__c} ] - [ {!ROUND(opp.Quantity,0)} ] - [ {!(opp.UnitPrice)} ] - [ {!(opp.TotalPrice)} ]

<messaging:attachment renderas="pdf" filename="Opportunity_Products.pdf">

<img src="" border="0"></img>

        <p>Dear {!},</p>
        <p>Below is a list of products related to the Opportunity:<b> {!}</b>.</p>
        <br/>Account: <i> {!}  </i> 
        <br/>Opportunity Owner: {!}
        <br/>Opportunity Amount: {!(relatedTo.Amount)}
        <br/>Opportunity Close Date: {!relatedTo.CloseDate} 

    <apex:datatable border="2" cellspacing="5" var="opp2" value="{!relatedTo.OpportunityLineItems}">
        <apex:facet name="header">Products associated with Opportunity {!}</apex:facet>
          <apex:column value="{!}" headerValue="Product Name"/>
          <apex:column value="{!opp2.Product_Family__c}" headerValue="Product Family"/>
        <apex:column value="{!opp2.Quantity}" headerValue="Quantity" />
        <apex:column value="{!opp2.UnitPrice}" headerValue="Units" />
        <apex:column value="{!opp2.TotalPrice}" headerValue="Total Price" />

What is the currenct currency?
current was $
Just put "$" in front of your merge field.

For eg: <td> $ {!(opp.TotalPrice)} </td>

Note: This is not ideal solution if you have multiple currencies.
if we have multiple currency then?
In that case you can use formula fields to store the currency symbol. After that show the formula field before each currency ammount.
Gurmeet Singh15Gurmeet Singh15
Please try using : CurrencyIsoCode field