1

I'm trying to create a validation rule that will prevent a user from selecting an option in a dropdown on an Account field if none of the related contacts have a field marked true.

Example:

  • Account field = "Ready for handoff" is a picklist with two yes options (one requiring further work and the other doesn't) let's call them Yes1 and Yes2, and one no option.

  • Contact field = "Used for outreach" is a boolean checkbox.

I want the validation rule to trigger if the user selects Yes1 in the account field and none of the related contacts have the checkbox checked. If at least one of the contacts have that checkbox checked, then the Yes1 option can be selected. Yes2 and No can be selected without this contact field needing to be filled out.

I've built a contact validation rule relating back to the account field, but don't see the option to build an account validation rule that relates to the contact object.

I'm struggling to relate the validation rule to related contacts since the account is the parent to the contact. Is this even possible?

1 Answer 1

1

Because we can't reference child records in formulas, we have a couple of options:

  1. Write the validation logic in Apex.
  2. Leverage a rollup framework or create a record-triggered flow on the contact to aggregate the count of contacts with the Used for Outreach checkbox to a new field on the Account, and reference this field in the validation rule.
1
  • 1
    Got it - thanks! I'm not familiar enough with Apex to write that code and option two was my backup plan if someone else confirmed the parent-child relationship. I'll go that route for this. Appreciate the help!
    – Jeremy
    Aug 23, 2022 at 19:46

You must log in to answer this question.

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