You need to sign in to do that
Don't have an account?
Need to display a String for a currency field if it has no value in it - VF page
I have a VF page that has the following line,
<td align="center"><apex:outputField value="{!pc.Waste1_Ctr_Box1_Fee__c}"/></td>
pc.Waste1_Ctr_Box1_Fee__c is a currency field in an object that is set in the controller. My requirement is to diplay "N/A" if there is no value in that field. Can I do that?
I tried to change outputField to OutputText and put a property variable say "nastr" of type String and set it to 'N/A' if there is no value in the field. for example,
<td align="center"><apex:outputText value="{!IF(NOT(ISNULL(pc.Waste1_Ctr_Box2_Fee__c)),pc.Waste1_Ctr_Box2_Fee__c,nastr)}"/></td> but it gives me an error. Does the property variable need to be only decimal since the field is a currency field? If I change it to Decimal and set it to 0, it works but the $ sign is missing and there is only one place after the decimal.
Is there any way that the currency field can display "N/A" when there is no value in it. Any input is greatly appreciated.
Thank You!
Thank You very much!
With your suggestion, this is what I had and it works.
<tdalign="center">
<apex:outputTextrendered="{!ISNULL(pc.Waste1_Ctr_Box1_Fee__c)}"value="N/A"/>
<apex:outputTextrendered="{!NOT(ISNULL(pc.Waste1_Ctr_Box1_Fee__c))}"value="{0,number,$#,###,###.00}">
<apex:paramvalue="{!pc.Waste1_Ctr_Box1_Fee__c}"/>
</apex:outputText></td>
Thank You once again!
All Answers
Yes, since it is a decimal field, you cannot give it a value of "NA".
What you can do is, take <apex:outputField> along with an <apex:outputText> , use the outputText to display NA, when there is no value in the field.
You can handle their visibilities using rendered.
Something like:
<td align="center">
<apex:outputField value="{!pc.Waste1_Ctr_Box1_Fee__c}" rendered="{!pc.Waste1_Ctr_Box1_Fee__c != NULL}"/>
<apex:outputText value="NA" rendered="{!pc.Waste1_ctr_Box1_Fee__c == NULL}"/>
</td>
Thank You very much!
With your suggestion, this is what I had and it works.
<tdalign="center">
<apex:outputTextrendered="{!ISNULL(pc.Waste1_Ctr_Box1_Fee__c)}"value="N/A"/>
<apex:outputTextrendered="{!NOT(ISNULL(pc.Waste1_Ctr_Box1_Fee__c))}"value="{0,number,$#,###,###.00}">
<apex:paramvalue="{!pc.Waste1_Ctr_Box1_Fee__c}"/>
</apex:outputText></td>
Thank You once again!