+ Start a Discussion

Checking for empty fields

new to apex coding and wondering how I can check if a field in a custom record is empty? Particulary, I want to know what the "if condition" in apex code looks like for "integer" and "string"data types.
You have to check for null in both cases.
If(nameOfField__c == null){
        //Your code

Satish Kumar

Hi Reza,

you can use in this way

//For string fields
if(yourCustomStringField__c != '' && yourCustomStringField__c != null) {

//your logic here

//For Integer field
for(integerFied__c != null) {
//You logic here