Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 5
    It's worth noting that this is effectively a combination of 1 and 2 in @RobertSosemann's post as it catches both null and ''. Commented May 20, 2015 at 7:58
  • 1
    and it would even catch strings with white space only like ' '. Commented May 20, 2015 at 9:24
  • 7
    Note: If checking from a query, pre- and post-whitespace is automatically trimmed, and if the result would be an empty space, the field is instead null. That means that you virtually never need to check for '' (empty string). Commented May 20, 2015 at 15:53
  • Thanks. It's like the difference between String.IsNullOrEmpty and String.IsNullOrWhiteSpace in C#/.NET. Commented Jan 4, 2018 at 18:35
  • There are also isNotEmpty() and isNotBlank(), please check out the official docs here: developer.salesforce.com/docs/atlas.en-us.apexcode.meta/… Commented May 21, 2020 at 18:42