Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

How to check in string isblank Apex?

Asked by Claudine Tippins May 11, 2023 3.6K views 1 answer
Share

About this question

I'm unsure what's the shortest and most robust way to check whether a Text field is blank / empty?

/*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() == 0;

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.