[SalesForce] Validation rule to accept only certain values in a Multi-Select picklist based on another field

I am trying create a validation rule to make sure only certain values are accepted in a Multi-Select picklist when an another field's value.

For example

Value of choices__c(Multi-Select picklist) should only be choice1, choice3 and choice5 if value of Family__c(formula field of text type) is X. If the value of Family__c is anything else other than 'X' choices__c can be anything.

I am really not sure how do i equate the Multi-Select picklist value with text formula

Best Answer

EDIT 1 If you want to allow any value of choice1, choice3, or choice5 but do not want to allow choice2, choice4, or choice6 then you should create rule like this

 if(Family__c == 'X', 
        if( 
            OR(
                INCLUDES(choices__c,'choice2'), 
                INCLUDES(choices__c,'choice4'),
                INCLUDES(choices__c,'choice6')
            ), 
            True, 
            False
        ),
        False
    )

You can use formula something like bellow:

if(Family__c == 'X', 
    if(TEXT(choices__c) == 'choice1; choice3; choice5', 0, 1),0)

So basically the idea is to check the value of Family__c.

If value of Family__c Is X Then check additional condition else return false.

The additional condition should check if Text value of choices__c is 'choice1; choice3; choice5' then it should return false or else true.

When validation rule returns true it shows error to user and stop the processing.

Related Topic