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
wendy chan 3wendy chan 3 

Curreny formatting in OutputText

I`m using below Outputtext to show negative values in brackets. For example, -1,000.00 to reflect as (1,000.00)
 
<td>$<apex:outputText value="{0, Number, Currency}">   <apex:param value="{!target}" /> </apex:outputText></td>



Above line works fine except that I want to get rid of decimals. Negative value should appear like this (1,000) without decimals. Can someone please suggest a better way to achieve this? Can I achieve this using LEFT or Right Funtion?
Shruti SShruti S
Give this a shot -
<td>
    <apex:outputPanel rendered="{!target > 0}" layout="none">
        $<apex:outputText value="{0, Number, Currency}">
            <apex:param value="{!target}" />
        </apex:outputText>
    </apex:outputPanel>
    <apex:outputPanel rendered="{!target < 0}" layout="none">
        ({!TEXT(target)})
    </apex:outputPanel>
</td>
wendy chan 3wendy chan 3

Thanks Shruti. I tried this but now it shows value like this (-1000). Also, it still shows minus sign and doesnt show commas

wendy chan 3wendy chan 3
I want to show value like this (1,000)
Shruti SShruti S

You can use the ABS() to get a non-negative value. An <apex:outputText> tag can be used to display the number in a Integer format. Refer this link to know more about <apex:outputText> tag - https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_outputText.htm (https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_outputText.htm" target="_blank)

Please try out the below code - 

<td>
    <apex:outputPanel rendered="{!target> 0}" layout="none">
        <apex:outputText value="{0, Number, Currency}">
            <apex:param value="{!target}" />
        </apex:outputText>
    </apex:outputPanel>
    <apex:outputPanel rendered="{!target< 0}" layout="none">
        (<apex:outputText value="{0, Number, Integer}">
            <apex:param value="{!ABS(target)}" />
        </apex:outputText>)
    </apex:outputPanel>
</td>