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
courtneybcourtneyb 

Validation Rule to Show Error when more than one Checkbox is Selected

Hello

 

My organization has a few customized address fields which required me to create workflow/field update checkboxes related to these specific addresses.  I am trying to set up a validation rule that will prevent users from saving a record if more than one "Preferred Address" checkbox is selected.

 

Specifically, the 3 checkbox fields I have created are:

Mother Preferred Address

Father Preferred Address

Guardian Preferred Address

 

I haven't had any luck figuring out the formula that would allow me to set up this validation rule.  Any suggestions?

 

Many thanks! 

Best Answer chosen by Admin (Salesforce Developers) 
Jeremy.NottinghJeremy.Nottingh

There are only four cases that are allowed, so it's not too much trouble to specify them separately. This rule will fire if it's not one of those four cases.

not( or(
   and(checkbox1,!checkbox2,!checkbox3),
   and(!checkbox1,checkbox2,!checkbox3),
   and(!checkbox1,!checkbox2,checkbox3),
   and(!checkbox1,!checkbox2,!checkbox3)
))

 

 

All Answers

Jeremy.NottinghJeremy.Nottingh

There are only four cases that are allowed, so it's not too much trouble to specify them separately. This rule will fire if it's not one of those four cases.

not( or(
   and(checkbox1,!checkbox2,!checkbox3),
   and(!checkbox1,checkbox2,!checkbox3),
   and(!checkbox1,!checkbox2,checkbox3),
   and(!checkbox1,!checkbox2,!checkbox3)
))

 

 

This was selected as the best answer
courtneybcourtneyb

Awesome!  Thanks so much for the quick reply!