ISBLANK vs ISNULL

One of the advantages of Salesforce platform is its declarative features, in that i will give a thumbs up for formulas which helps me in most of the use cases. Formula field takes a little bit of calculation out side of the programming and make our tasks easily achievable.

But when someone starts learning the formula functions there is always a little confusion between ISBLANK() and ISNULL() formula methods.

The following questions may occur in ones mind

  • Does these functions actually differ from each other or are they same? 
  • If same why Salesforce provide two different formula functions for same purpose?

To answer these different bubbles in your mind, lets do the real test, create a formula field and test for different fields and scenarios.

Lets test these two field types

  1. Number 
  2. Text

While creating a formula you have noted that there are two radio boxes available below the formula editor.

  • Treat blank fields as zeroes (This option treats blank value as zero , so a value will be present. Its useful if you are creating a formula which returns number value.)
  • Treat blank fields as blanks (This options treats the blank as bank , useful while creating text formuals.)

Please refere the the below image.

Combing these two parameters and two different formula functions totally we have eight scenarios in hand.

Lets test it out, The following test does not have any value present in both text and number field including whitespace.

S NO Formula function Formula option Field type Result
1 ISBLANK() Treat blank fields as zeroes  Text True
2 ISBLANK() Treat blank fields as blanks Text True    
3 ISBLANK() Treat blank fields as zeroes Number False
4 ISBLANK() Treat blank fields as blanks Number True
5 ISNULL() Treat blank fields as zeroes Text False
6 ISNULL() Treat blank fields as blanks Text False
7 ISNULL() Treat blank fields as zeroes Number False
8 ISNULL() Treat blank fields as blanks Number True

 

 

 

 

 

 

 

The output of table shows the various scenarios and its output.

So from the output its clear that both the formula functions are not same and they behave different for different field types.

So to check a text field has no value entered use ISBLANK() function.

To check number field has no value entered either you can use ISBLANK() function  or use ISNULL() function and set that formula option to Treat blank fields as blanks.

 

Please let me know your thoughts in comment section.

Have a great day smiley...

 

Rating: 
No votes yet