2

I have an IF condition in my outputtext field. I want to display 0.00 if the value is not exist into the field. Below is the condition that I am using to display the value

<apex:outputText  rendered="{!IF(CONTAINS(it.oppName, 'xxxxx'),true, false)}" value="{!ti.Name__c}"/>

May I know how to display 0.00 instead of empty when the value is not available.

3

You can use formula in value of apex:outputText as well.

<apex:outputText  rendered="{!CONTAINS(it.oppName, 'xxxxx')}" value="{!IF(CONTAINS(it.oppName, 'xxxxx'),ti.Name__c, '0.00')}"/>

Hope it helps.

| improve this answer | |
  • 2
    Always replace IF(condition, true, false) with just condition. – Adrian Larson Aug 3 '16 at 13:37
  • @AdrianLarson Your suggestion works for rendered but for value have to use IF condition there. Updated the answer. – Vigneshwaran G Aug 3 '16 at 13:39
  • 1
    Yep exactly. Not saying IF is always bad. – Adrian Larson Aug 3 '16 at 13:40
  • Hi I tried the above option, but its still coming as null only. That Name__c field is number field so I changed the condition to <apex:outputText rendered="{!CONTAINS(it.oppName, 'xxxxx')}" value="{!IF(ti.Name__c != NULL,ti.Name__c, '0.00')}"/>... I think the issue is we are checking if name__c is null or not, but we should check oppName – KSL Aug 3 '16 at 13:56
  • @KSL You can use 'ISNULL(ti.Name__c)' instead of 'ti.Name__c != NULL', looks nicer and works better.. – Yonathan Goriachnick Aug 3 '16 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.