function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rezasadoddin1.3878325535858708E12rezasadoddin1.3878325535858708E12 

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.
Satish_SFDCSatish_SFDC
You have to check for null in both cases.
If(nameOfField__c == null){
        //Your code
}

Regards,
Satish Kumar

Abhi_TripathiAbhi_Tripathi
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

}