You need to sign in to do that
Don't have an account?
Sunny670
Can someone please look why this is not working?
Hi all, below is my code peice.
<apex:outputText value="{0, number, $###,###,###,###,###}" rendered="{!if(my field<>null,(if( my field< 0, '(' + text(abs(my field)) + ')',text(my field))),my field)}">
<apex:param value="{!my field}"/>
</apex:outputText>
if my field value is = -20 expected output:($20) but i am getting as -$20.
String formatted = decVal.format();
formatted = formatted.startsWith('-') ? ('($' + formatted.remove('-') + ')') : ('$' + formatted);
devfja is right, you are using the rendered attribute in a slightly incorrect way. Rendered is supposed to be a boolean value, but you are using it as though you could return a numberic value to display. So, I'm not sure why it was working before as you claim.
Regarding your question, the syntax my field<>null doesn't work in this context. Instead, you can try using NOT(ISNULL(my field))
You might want to also try creating two different outputText fields, one renders TRUE if the number is non-negative, the other one renders TRUE if the number is negative. That way you should be able to have 2 different formatting strings without going into your controller.
<apex:outputText value="{0, number, $###,###,###,###,###}" rendered="{!AND(NOT(ISNULL(my field)), my field>=0)}">
<apex:param value="{!my field}"/>
</apex:outputText>
<apex:outputText value="{0, number, ($###,###,###,###,###)}" rendered="{!AND(NOT(ISNULL(my field)), my field<0)}">
<apex:param value="{!ABS(my field)}"/>
</apex:outputText>