5

I was working on a validation rule formula, and noticed that whatever criteria I provided, the formula was returning true. I stripped out the criteria in the formula, until I had a simple formula:

ISBLANK( BillingState )

Validation Rule

This formula is returning true regardless of what I put into the standard BillingState field on the standard Account object.

BillingState with valid value, and error message BillingState with invalid value, and error message

Once I add a value to the field, I would expect ISBLANK(...) to return false, and allow the record to be saved, but this doesn't seem to be the case.

5
  • 1
    There is the option in formulas, treat blank field as zeroes. Make sure it's set to treat as blank Commented Jul 26, 2016 at 15:43
  • I don't believe that option is supported in validation rules, @IlyaLepesh. I'm unable to locate the option when editing the validation rule. Commented Jul 26, 2016 at 15:46
  • 1
    Can you check if any triggers clear that field out? The only way I was able to repro was when before triggers set it to null.
    – Adrian Larson
    Commented Jul 26, 2016 at 15:59
  • Are you using the State and Country picklists? If so, you should be using BillingStateCode instead.
    – sfdcfox
    Commented Jul 26, 2016 at 16:06
  • 1
    I had just started looking into the related triggers more deeply, and that was the cause. A before update trigger was trying to assign an empty value to the field based on a related object (which was part of the original validation rule). I would have expected a DmlException, rather than the error showing back up on the page, as a validation error. Commented Jul 26, 2016 at 16:06

1 Answer 1

5

I have experienced similar behavior when I had a before trigger that cleared out the value. This can cause an unfortunate User Experience where it looks like the field is filled in, but in reality the save fails because the field gets set to null before the validation is performed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .