0

I have trouble with this validation rule on Account. It should allow changes on MainBrand__c only if MainBrand__pr.WebsiteRelevant__c = true and RegistrationDoubleOptin__c = true. I tried this but not working:

AND(
            ISCHANGED(MainBrand__pc),

            MainBrand__pr.WebsiteRelevant__c,

            RegistrationDoubleOptIn__pc
)

2 Answers 2

1

You should write a formula for the negative cases, not for the right one.
The validation rule should be triggered when MainBrand__c has been changed and either MainBrand__pr.WebsiteRelevant__c or RegistrationDoubleOptin__c are false (see De Morgan's laws, so the formula should be

AND(
    ISCHANGED(MainBrand__pc),
    OR(
        NOT(MainBrand__pr.WebsiteRelevant__c),
        NOT(RegistrationDoubleOptin__c)
    )
)
0

I think the problem with your validation rule is that you are using the wrong logical operator. You should use OR instead of AND, because you want to allow changes on MainBrand__c only if either of the two conditions are true, not both. Try this:

OR(
   NOT(ISCHANGED(MainBrand__pc)),
   AND(
       MainBrand__pr.WebsiteRelevant__c,
       RegistrationDoubleOptIn__pc
   )
)

This validation rule will only fire if MainBrand__c is changed and both MainBrand__pr.WebsiteRelevant__c and RegistrationDoubleOptIn__pc are false. Otherwise, it will allow the record to be saved.

1
  • 1
    Since you put NOT(ISCHANGED(MainBrand__pc)) in OR with a different expression, the validation rule will be trigger everytime MainBrand__pc isn't changed, so everytime a user update any other field except MainBrand__pc
    – RubenDG
    Commented Sep 11, 2023 at 7:49

You must log in to answer this question.

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