Which is better - isblank and isnull in salesforce

638    Asked by DavidEDWARDS in Salesforce , Asked on Sep 22, 2022

But I think ISNULL works on text fields. What do you guys think? Which one is to be used?

Answered by James SCOTT

Among isblank and isnull in salesforce

I think it's likely to depend on the scenario in question, but you should be aware that ISNULL does not work the same way as ISBLANK for text.

When dealing with text and lookup fields, a blank value in the field yields true for ISBLANK() but false for ISNULL()—even if you set a text field to null in apex it is still treated as blank (i.e. not null) in the formula.

Essentially the system works the same way as you'd expect in a programming language: an empty string is not the same as a null value, it is still an instance of a string.



Your Answer

Interviews

Parent Categories