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
Walter@AdicioWalter@Adicio 

How do I show a variable as currency?

Here are the parts I am using.

 

public Double totalDeposit { get; set;} {totalDeposit = 0.0;}

 

 

for(SFDC_520_QuoteLine__c mql : [Select s.Unit_Net_Price__c,s.Qty_Ordered__c,s.Product2__r.Fee_Type__c From SFDC_520_QuoteLine__c s]) { if(mql.Optional_Item__c==false && (mql.Product2__r.Fee_Type__c=='One Time Setup' || mql.Product2__r.Fee_Type__c=='Monthly Fee') ) { totalDeposit += mql.Unit_Net_Price__c * mql.Qty_Ordered__c; } }

 

 

<apex:outputText value="{!totalDeposit}"/>

 

 

Best Answer chosen by Admin (Salesforce Developers) 
MukulMukul

Yes. I have done a similar thing in another language. You will have to do a nested if statements (since we cant do Switch case here.) and use all String functions. I can post the snippet of code here -

 

String myCurrency = "10000"; // Whatever you get from your Code

String myFinalCurrency;

if(myCurrency.length() > 4) {

   // Split it from 3rd number and add comma

.....so on

All Answers

MukulMukul

One way to do it will be type casting it into String and prefixing it with dollar sign and adding commas in the String.

 

Regards

Mukul

Walter@AdicioWalter@Adicio
Thanks Mukul . Do you have any / seen any examples of how I get the comas in the right spot?
MukulMukul

Yes. I have done a similar thing in another language. You will have to do a nested if statements (since we cant do Switch case here.) and use all String functions. I can post the snippet of code here -

 

String myCurrency = "10000"; // Whatever you get from your Code

String myFinalCurrency;

if(myCurrency.length() > 4) {

   // Split it from 3rd number and add comma

.....so on
This was selected as the best answer
Walter@AdicioWalter@Adicio
Thanks again Mukul .