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

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