You need to sign in to do that
Don't have an account?

How to replace null or empty number value with 0 - in VF
How to replace null or empty value with 0.
I am passing 12 number fields to a Google chart.
If one of my fields is blank the chart does not render.
In my Visualforce page I what to replace the null value with 0.
Both of the following lines of code always return false even though one is ==null and the other is !=null.
['January', {!if(Contact.Sales_01__c==null, 0, Contact.Sales_01__c}],
['January', {!if(Contact.Sales_01__c!=null, 0, Contact.Sales_01__c}],
How do I do this in Visualforce without using a controller extension?
Another question: can I use a static Apex method and pass in the value and get back 0 if null, or the passed value not null?
Thanks.
Hi,
you can do that with visualforce page in the following way -
['January', {!IF(OR(ISNULL(Contact.Sales_01__c),ISBLANK(Contact.Sales_01__c)), 0, Contact.Sales_01__c}],
Hope it would help !
All Answers
Hi,
you can do that with visualforce page in the following way -
['January', {!IF(OR(ISNULL(Contact.Sales_01__c),ISBLANK(Contact.Sales_01__c)), 0, Contact.Sales_01__c}],
Hope it would help !
Thanks Alok - this worked! Amazing.
Where should I have looked to find this?
I searched the Visualforce documentation and isNull has one hit but isEmpty found 0.
The Apex documentation has isEmpty for collections.
Thanks again.
My bad - I should have been looking for isBlank.
Found it in the Functions section of the Visualforce documentation.
Still, you can't always find everything in the documentation. Sometimes the solution you want is a combination of documentations, programming practises and some nifty thinking. That's what the community is for !