[SalesForce] How to create a validation rule based on two picklist values and two multi-picklist fields

I want to make it so that only accounts with a Type of "Client" or "Client – Group Contract" can have services. The "Type" field is a picklist, while the "Services" fields are multi-picklists. I want the multi-picklists to be blank on accounts that aren't clients.

I can do this, without errors in syntax:

AND(NOT(ISPICKVAL( Type, "Client")), NOT ISBLANK(Services_Purchased__c))

But this doesn't work:

AND(NOT(ISPICKVAL( Type, "Client", "Client - Group Contract"))), NOT ISBLANK(Services_Purchased__c, Services_Licensed__c)))

I'm getting the idea that I can't do this with ISPICKVAL, but considering the types of fields I'm working with, what else can I use?

Best Answer

AND(
NOT(OR(ISPICKVAL(Type, "Client"),ISPICKVAL(Type, "Client - Group Contract"))), 
NOT(AND(ISBLANK(Services_Purchased__c),ISBLANK(Services_Licensed__c))))

This translates into:

If Type is not "Client" or "Client-Group Contact", and both Services_Purchased__c and Services_Licensed__c are not blank, throw a validation error.

Related Topic