You need to sign in to do that
Don't have an account?
Elmiland
Null != Field vs. Field != Null
Before updating a field ABC, I need to check whether the field is passed as null/blank, if yes, then dont update it.
Can someone advise if there is a difference between the two options below, and if yes, what I should be aware of? I am interested if wither there is a best practice, potential compile errors, or anything else.
Option 1:
if ( null != ABC && '' != ABC ) {
abc.ABC__c = ABC;
}
Option 2:
if ( ABC != null && ABC != '' ) {
abc.ABC__c = ABC;
}
Thank you!
Can someone advise if there is a difference between the two options below, and if yes, what I should be aware of? I am interested if wither there is a best practice, potential compile errors, or anything else.
Option 1:
if ( null != ABC && '' != ABC ) {
abc.ABC__c = ABC;
}
Option 2:
if ( ABC != null && ABC != '' ) {
abc.ABC__c = ABC;
}
Thank you!
Salesforce documentation says:
if (!String.isBlank(ABC)) {
}