+ Start a Discussion
U JayU Jay 

Can i convert a number / currency to TEXT without lose trailing zeroes.

Can i convert a number / currency to TEXT without lose trailing zeroes.

<apex:outputText value="{!SUBSTITUTE(TEXT(additionalCost.List_Price__c),'.',',')}" />
Bhanu MaheshBhanu Mahesh
Hi Jyothy,

You can do this by using decimal methods available in apex

If you are using any Extension or controller try below code

Try below work around
//In page relace the value with a string which will get value from Controller or Extension
<apex:outputText value="{!currStr}" />

//In Controller or Extension
public currStr{get;set;}
//converting the currency to string and replacing '.' with ','
if(additionalCost.List_Price__c != null){
	currStr = additionalCost.List_Price__c.toPlainString().replace('.',',');    
}

Mark this as "SOLVED" if your issue is Resolved

Regards,
Bhanu Mahesh

 
U JayU Jay
When i refreshed the preview i got error invalid , within the decimal number when i tried this as
additionalCost.List_Price__c = additionalCost.List_Price__c.toPlainString().replace('.',',');
additionalCostList(additionalCost);
Since i have to loop over the list of additional costs on the visual force page (i have to us as < list variable>.List_Price__c . Cant use currStr.

My current code : -
<apex:outputPanel rendered ="{! If(TEXT(additionalCost.List_Price__c).Split(),true,true) }">
                       <apex:outputText value="{!countryCurrencySymbol} {!SUBSTITUTE(TEXT(additionalCost.List_Price__c)+'0','.',',')}" rendered="{!NOT(ISNULL(additionalCost.List_Price__c))}"/>
                   </apex:outputPanel>
It works but if value is 12.30 shows as 12,3 where i need 12,30.

Thanks Bhanu for your interest on this question. can you help me with this need?

 
Bhanu MaheshBhanu Mahesh
Hi Jyothy,

If it is important for you, then work around would be go for Wrapper class and display the values from wrapper class.

In wrapper class you can prepare the required string and display it.

Because TEXT(Currency field) will automatically remove the trailing zeroes.

Try to paste your code so that I can help if you need any help

Regards,
Bhanu Mahesh
U JayU Jay
Worked with this :-
<apex:outputPanel rendered="{!IF((FIND('.',TEXT(priceBreakDownListItem.List_Price__c)) != 0) && ( LEN(TEXT(priceBreakDownListItem.List_Price__c))- FIND('.',TEXT(priceBreakDownListItem.List_Price__c)) >= 2), true, false) }"> <apex:outputText value="{!countryCurrencySymbol} {!SUBSTITUTE(TEXT(priceBreakDownListItem.List_Price__c),'.',',')}" rendered="{!NOT(ISNULL(priceBreakDownListItem.List_Price__c))}"/> </apex:outputPanel>