You need to sign in to do that
Don't have an account?
SFDCTech1
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"
relatedToType="Opportunity"
subject="Productline Items for Opportunity: {!relatedTo.name}"
replyTo="support@acme.com" >
<messaging:htmlEmailBody >
<html>
<body>
<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}
</STYLE>
<font face="arial" size="2">
<p>Dear {!recipient.name},</p>
<p>Below is a list of products related to the Opportunity:<b> {!relatedTo.name}</b>.</p>
<br/>Account: <i> {!relatedTo.Account.name} </i>
<br/>Opportunity Owner: {!relatedTo.owner.name}
<br/>Opportunity Amount: {!relatedTo.Amount}
<br/>Opportunity Close Date: {!relatedTo.CloseDate}
<p/>
<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>
</tr>
<apex:repeat var="opp" value="{!relatedTo.OpportunityLineItems}">
<tr>
<td><a href="https://na1-blitz01.soma.salesforce.com/{!opp.id}">View</a> |
<a href="https://na1-blitz01.soma.salesforce.com/{!opp.id}/e">Edit</a></td>
<td>{!opp.PriceBookEntry.name}</td>
<td>{!opp.Product_Family__c}</td>
<td>{!(opp.Quantity)}</td>
<td>{!(opp.UnitPrice)}</td>
<td>{!(opp.TotalPrice)}</td>
</tr>
</apex:repeat>
</table>
<p />
</font>
</body>
</html>
</messaging:htmlEmailBody>
<messaging:plainTextEmailBody >
Dear {!recipient.name},
Below is a list of products related to the Opportunity: {!relatedTo.name}
Account: {!relatedTo.Account.name}
Opportunity Owner: {!relatedTo.owner.name}
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.PriceBookEntry.name} ] - [ {!opp.Product_Family__c} ] - [ {!ROUND(opp.Quantity,0)} ] - [ {!(opp.UnitPrice)} ] - [ {!(opp.TotalPrice)} ]
</apex:repeat>
</messaging:plainTextEmailBody>
<messaging:attachment renderas="pdf" filename="Opportunity_Products.pdf">
<img src="http://www.salesforce.com/common/assets/css/images/hdr_apexdn.gif" border="0"></img>
<p>Dear {!recipient.name},</p>
<p>Below is a list of products related to the Opportunity:<b> {!relatedTo.name}</b>.</p>
<br/>Account: <i> {!relatedTo.Account.name} </i>
<br/>Opportunity Owner: {!relatedTo.owner.name}
<br/>Opportunity Amount: {!(relatedTo.Amount)}
<br/>Opportunity Close Date: {!relatedTo.CloseDate}
<p/>
<apex:datatable border="2" cellspacing="5" var="opp2" value="{!relatedTo.OpportunityLineItems}">
<apex:facet name="header">Products associated with Opportunity {!relatedTo.name}</apex:facet>
<apex:column value="{!opp2.PriceBookEntry.name}" 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" />
</apex:datatable>
</messaging:attachment>
</messaging:emailTemplate>
<messaging:emailTemplate recipientType="Contact"
relatedToType="Opportunity"
subject="Productline Items for Opportunity: {!relatedTo.name}"
replyTo="support@acme.com" >
<messaging:htmlEmailBody >
<html>
<body>
<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}
</STYLE>
<font face="arial" size="2">
<p>Dear {!recipient.name},</p>
<p>Below is a list of products related to the Opportunity:<b> {!relatedTo.name}</b>.</p>
<br/>Account: <i> {!relatedTo.Account.name} </i>
<br/>Opportunity Owner: {!relatedTo.owner.name}
<br/>Opportunity Amount: {!relatedTo.Amount}
<br/>Opportunity Close Date: {!relatedTo.CloseDate}
<p/>
<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>
</tr>
<apex:repeat var="opp" value="{!relatedTo.OpportunityLineItems}">
<tr>
<td><a href="https://na1-blitz01.soma.salesforce.com/{!opp.id}">View</a> |
<a href="https://na1-blitz01.soma.salesforce.com/{!opp.id}/e">Edit</a></td>
<td>{!opp.PriceBookEntry.name}</td>
<td>{!opp.Product_Family__c}</td>
<td>{!(opp.Quantity)}</td>
<td>{!(opp.UnitPrice)}</td>
<td>{!(opp.TotalPrice)}</td>
</tr>
</apex:repeat>
</table>
<p />
</font>
</body>
</html>
</messaging:htmlEmailBody>
<messaging:plainTextEmailBody >
Dear {!recipient.name},
Below is a list of products related to the Opportunity: {!relatedTo.name}
Account: {!relatedTo.Account.name}
Opportunity Owner: {!relatedTo.owner.name}
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.PriceBookEntry.name} ] - [ {!opp.Product_Family__c} ] - [ {!ROUND(opp.Quantity,0)} ] - [ {!(opp.UnitPrice)} ] - [ {!(opp.TotalPrice)} ]
</apex:repeat>
</messaging:plainTextEmailBody>
<messaging:attachment renderas="pdf" filename="Opportunity_Products.pdf">
<img src="http://www.salesforce.com/common/assets/css/images/hdr_apexdn.gif" border="0"></img>
<p>Dear {!recipient.name},</p>
<p>Below is a list of products related to the Opportunity:<b> {!relatedTo.name}</b>.</p>
<br/>Account: <i> {!relatedTo.Account.name} </i>
<br/>Opportunity Owner: {!relatedTo.owner.name}
<br/>Opportunity Amount: {!(relatedTo.Amount)}
<br/>Opportunity Close Date: {!relatedTo.CloseDate}
<p/>
<apex:datatable border="2" cellspacing="5" var="opp2" value="{!relatedTo.OpportunityLineItems}">
<apex:facet name="header">Products associated with Opportunity {!relatedTo.name}</apex:facet>
<apex:column value="{!opp2.PriceBookEntry.name}" 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" />
</apex:datatable>
</messaging:attachment>
</messaging:emailTemplate>
For eg: <td> $ {!(opp.TotalPrice)} </td>
Note: This is not ideal solution if you have multiple currencies.