Writing a Salesforce formula and my if statement is comparing whether two fields are equal to one another (ie. Field1 == Field2). However it appears to evaluate them as false if both the fields are blank. It is a numerical formula so the option to treat fields as blanks or zeros exists. When I switch it to treat blank fields as zero, the two “blank” fields equality evaluates to true (but unfortunately I need to use isblank later on in the formula so that will not work). Am I on the right track with the fact that two blank fields don’t equal one another? I feel like they should both be null though. Is there any best practices in terms of dealing with blank fields and equality?
1 Answer
This knowledge article mentions:
To avoid blank values resulting for formula calculations, it is recommended to select Treat blank fields as zeroes to always display a value for a formula field but this is completely dependent on your business needs.
Further, this trailhead mentions that you should not be tempted to use =
operator to check blank values, but ISBLANK()
It might be tempting to check if a field is empty by using the = (equal) or != (not equal) operators to see if it equals null. But the best practice is to use the built-in function ISBLANK().
So as long as you are following one of the approaches here, you are fine.