Activity Forums Salesforce® Discussions How to check if a string is empty in Apex in Salesforce?

  • Kirandeep

    Member
    August 28, 2020 at 2:31 pm

    Hi,
    You can use isEmpty() method of String Class which returns true if the specified String is Empty OtherWise returns false

    • This reply was modified 4 years, 2 months ago by  Kirandeep.
    • This reply was modified 4 years, 2 months ago by  Kirandeep.
  • Anuj

    Member
    August 28, 2020 at 3:07 pm

    public String CheckIt {get;set;}

    //Check IsNotEmpty
    public Boolean CheckisNotEmpty()
    {
    if(String.isNotEmpty(CheckIt))
    {
    //String is not empty ('') and not null
    return true;
    }
    else
    {
    //String is empty ('') or blank or null
    return false;
    }
    }
    }

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos