Differentiate "0" and blank

  • 1
  • Question
  • Updated 2 years ago
  • Answered
I understand that {{#blah}} is basically an "if" statement that checks if a field has a value, but for numerical fields a zero value will be counted as blank.  Is there a method to differentiate between a blank and a zero?  
Photo of Scott

Scott

  • 2,722 Points 2k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Scott

Scott

  • 2,722 Points 2k badge 2x thumb
Anyone have any thoughts on this?
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
You could use a Ui-Only Formula Field to differentiate between a field being zero or blank, e.g. a Checkbox Ui-Only field called "MyFieldIsZero" which returns true only if the value is explicitly zero

IF({{MyField__c}}==0,true,false)

Then in your page, where you were using {{#MyField__c}} you could instead do {{#MyFieldIsZero}}.... {{/MyFieldIsZero}}
(Edited)
Photo of Boris Bachovski

Boris Bachovski

  • 94 Points 75 badge 2x thumb
And how would do that for number fields? I can see you rely on Javascript, meaning that 0=='' is true. In this case how do I know whether a field has 0 value or is blank?