Is there a difference between the two statements?

{!NOT(ISNULL(variable))} and {!variable != null}

What is the appropriate way to check if something is null?

EDIT: What if it's a SF checkbox? Does != null validate if its unchecked or does this not apply here?

2 Answers 2


You can do either way but I prefer {!variable != null}.

One thing that might often be a better idea though is to do the checks in the controller so that less of the logic is in the VF page.

EDIT: SObject booleans will always be true/false. It won't be null.

  • Thanks! I added an edit - as it doesn't seem to apply to checkboxes. Could you address? :) Commented Sep 12, 2014 at 16:00
  • @JacobRaccuia html checkboxes or Visualforce checkboxes?
    – dphil
    Commented Sep 12, 2014 at 18:20
  • checkboxes from a salesforce object - is the box checked? Commented Sep 12, 2014 at 18:28
  • Checkboxes on a Salesforce object can never be null. They have two values, true or false.
    – greenstork
    Commented Sep 12, 2014 at 18:30
  • 1
    However, all apex variables, even booleans can have a null value. It really depends then on whether or not your are binding to an sObject or your own boolean property on your controller.
    – greenstork
    Commented Sep 12, 2014 at 18:33

Either syntax works, both are exactly the same.

  • 1
    True, it's really just a matter of whether you're more used to Excel-style formula syntax or programmer-ish syntax. However, ISNULL() is deprecated - use ISBLANK() instead. Commented Sep 14, 2014 at 3:57
  • If you're checking in the controller you may also use the String method isNotBlank(). However, in VF I don't believe there is an ISNOTBLANK() function, just ISBLANK(). Commented Sep 14, 2014 at 6:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .