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
jameskCAjameskCA 

Way to check for blank on both number and string?

I have a lot of fields to check for blank values on an object, both numbers and strings.  Would it be best to use the isBlank and convert number fields to strings and use the isBlank method?  Or, just create a new method that would check null, 0, or '' ?

If I created a new method with the above checks, would that work for both string and decimal?  Thanks in advance. 
@Karanraj@Karanraj
Use IsBlank which is supported for both number and text field. Check the salesforce documentation for more details - https://help.salesforce.com/apex/HTViewHelpDoc?id=customize_functions.htm
jameskCAjameskCA
That doesn't work in Apex - which is what I'm looking for.  Not formula fields.  
@Karanraj@Karanraj
Create one constructor helper class as below in your org and then you can utilize it in any your apex code to check the bull value for integer, string, decimal variable without worrying about the type of the variable.

Helper class to check null value for the different type of variable 
global class helperNullCheck {
    global static boolean helperNullCheck(integer i){
        return String.isBlank(String.Valueof(i));
    }
    global static boolean helperNullCheck(String i){
        return String.isBlank(i);
    }
    global static boolean helperNullCheck(Decimal i){
        return String.isBlank(String.Valueof(i));
    }
}
Sample use of helper class in your trigger/apex code
Integer intValue = 10;
String strValue ;
System.debug('Integer Value check'+ helperNullCheck.helperNullCheck(intValue));
System.debug('String Value check'+ helperNullCheck.helperNullCheck(strValue));