How to check if the field value is empty in APEX?

Hariprasath Thanarajah
2 min readJul 9, 2020

Null checking is an important functionality in every programming language. In different languages, the null checking differs from the way the other language check null.

In this post, we are going to discuss the null checking in Salesforce APEX.

The following are some of the null checkings in APEX,

1. Boolean isBlank = record.txt_Field__c == '';
2. Boolean isBlank = record.txt_Field__c == null;
3. Boolean isBlank = record.txt_Field__c.trim() == '';
4. Boolean isBlank = record.txt_Field__c.size()

--

--

Hariprasath Thanarajah

8+ yrs of experience in Software Development and became a certified Salesforce Developer to develop end-to-end Salesforce features in Salesforce platform.