+ Start a Discussion
Sarah OsburnSarah Osburn 

Enterprise Ed: How to replace null or empty number value with 0 - in VF

I'm getting a syntax error.  Sorry, I know this post is a bit old but the only discussion about this topic.  I want to replace a null value with $0.  Here is my line of code:

<td><apex:outputField value="{! IF(OR(ISNULL(ACT_ROF__c.Additional_Profits__c) ,ISBLANK(ACT_ROF__c.Additional_Profits__c)), 0, ACT_ROF__c.Additional_Profits__c }"/></td>

I'm apparently adding an extra comma somewhere but have no clue where.....??

Error: Syntax error. Extra ','
Sarah OsburnSarah Osburn
Disregard comment about old post, I was going to tag along on another post & decided not to.
kevin lamkevin lam
Missed a ")" near the end:

<td><apex:outputField value="{! IF(OR(ISNULL(ACT_ROF__c.Additional_Profits__c) ,ISBLANK(ACT_ROF__c.Additional_Profits__c)), 0, ACT_ROF__c.Additional_Profits__c) }"/></td>
Sarah OsburnSarah Osburn
Thanks, Kevin.  I added that ) in and am still getting the "Extra , Syntax"
kevin lamkevin lam
I think the error is because you're trying to display a zero in outputField, you need to change it to this:

<td><apex:outputText rendered="{!ISBLANK(ACT_ROF__c.Additional_Profits__c)}">0</outputText><apex:outputField value="{!ACT_ROF__c.Additional_Profits__c}" rendered="{!NOT(ISBLANK(ACT_ROF__c.Additional_Profits__c))}"/></td>

You don't need to check for ISNULL, it's covered by ISBLANK.
praveen murugesanpraveen murugesan
Hi Sarah,

We can't use output field for custom value. We need to use only when we are using filed either custom or standard.


as suggested by  kevin its should be like this

<td><apex:outputText value="{! IF(OR(ISNULL(ACT_ROF__c.Additional_Profits__c) ,ISBLANK(Image_Upload__c.Name)), 0, ACT_ROF__c.Additional_Profits__c) }"/></td>


<td><apex:outputText value="{! 0}" rendered="{!OR(ISNULL(ACT_ROF__c.Additional_Profits__c) ,ISBLANK(ACT_ROF__c.Additional_Profits__c))}"/></td>

<td><apex:outputField value="{! ACT_ROF__c.Additional_Profits__c}" rendered="{!OR(ACT_ROF__c.Additional_Profits__c!=NULL ,ACT_ROF__c.Additional_Profits__c!='')}"/></td>


Praveen Murugesan
Sarah OsburnSarah Osburn
Thank you both!  I'll try these and see what happens!  Thanks again!
Sarah OsburnSarah Osburn
Hi Kevin and Praveen, here is the code that worked:

<td><apex:outputText value="{!IF(ISBLANK(ACT_ROF__c.Additional_Profits__c),'$0',ACT_ROF__c.Additional_Profits__c)}"/></td>
kevin lamkevin lam
Hi Sarah,

What is the data type of the ACT_ROF__c.Additional_Profits__c field? That field may not be displayed correctly in the user's locale format if you use outputText.