2

I'm trying to figure out a nested IF statement for a validation rule on a custom object I've created. The goal of the validation rule is check to see if option 1 OR option 2 or option 3 is selected WHILE Field 1 is selected, OR see if option 4, option 5, option 6 is selected WHILE field 2 is selected.

I have each individual statement working on it's own, but where it all breaks down is when I try to evaluate for one or the other block. Here's an example of a block that works as hoped.

OR(
   ISPICKVAL(field1__c, "option1"),
   ISPICKVAL(field1__c, "option2"),
   ISPICKVAL(field1__c, "option3"),
   AND(
       ISPICKVAL(field2__c, "option1")))

When I try to add the OR statement to the mix is when it all breaks down. All input is accepted.

   OR(
   ISPICKVAL(field1__c, "option1"),
   ISPICKVAL(fiels1__c, "option2"),
   ISPICKVAL(field1__c, "option3"),
   AND(
       ISPICKVAL(field2__c, "option1")))
&&
OR(
   ISPICKVAL(field1__c, "option4"),
   ISPICKVAL(field1__c, "option5"),
   ISPICKVAL(field1__c, "option6"),
   AND(
       ISPICKVAL(field2__c, "option2")))

Can anyone see where I've gone wrong?

1 Answer 1

3

It sounds like you are going for something more like below. It looks like your AND statements are in the wrong place.

If (field2__c = "X1" AND field1__c IN ("Y1", "Y2", "Y3")) OR (field2__c = "X2" AND field1__c IN ("Y4", "Y5", "Y6")). If that logic is correct, your rule would look like:

OR(
    AND(
        ISPICKVAL(field2__c, "X1"),
        OR(
            ISPICKVAL(field1__c, "Y1"),
            ISPICKVAL(fiels1__c, "Y2"),
            ISPICKVAL(field1__c, "Y3")
        )
    ),
    AND(
        ISPICKVAL(field2__c, "X2"),
        OR(
            ISPICKVAL(field1__c, "Y4"),
            ISPICKVAL(fiels1__c, "Y5"),
            ISPICKVAL(field1__c, "Y6")
        )
    )
)
0

You must log in to answer this question.

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