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
QMEQME 

Validation rule: Enabling Field Dependency

I’m trying to use a validation rule to make a field required depending on the value of another field.

 

I have 2 fields

  • FieldA – (Type = Checkbox)
  • FieldB – (Type = Text 255 chars)

 

If FieldA is set (ie the checkbox is checked), I want to make FieldB mandatory.  I created the following validation rule which would evaluate to TRUE and subsequently show an error message on Field B:

 

AND(FieldA <> null, ISBLANK(FieldB))

 

Unfortunately this does not work.  When I check the checkbox for FieldA and leave FieldB blank, I get no error message - What am I doing wrong? 

 

Also, the ISBLANK(expression) does not seem to work on fields that are of type Checkbox, so I had changed my expression.

 

Any ideas?  This seems to be pretty basic

Best Answer chosen by Admin (Salesforce Developers) 
SargeSarge

Since FieldA is a checkbox, which stores boolean values, the validation rule should stick to only two possible values when comparing. i.e true or false. Hence the following will help

 

AND(

             FieldA = true,

             ISBLANK(FieldB)

)