[SalesForce] Validation Rule – If Picklist Values Selected, Lookup must be a certain Profile

I am trying to write a Validation Rule that says:

If a Picklist has specific values selected, then a lookup field named "New User" on the same page must be only allowed to select a User from the lookup with a certain profile type, or there would be an error shown. Here is what I have done so far and it is not working:

AND(
NewUser__c $Profile.Name = "Seller",
OR(
ISPICKVAL(Style__c, 'Magazine'),
ISPICKVAL(Style__c, 'Digital'),
ISPICKVAL(Style_Type__c, 'Media')
)
)

I think the AND statement is completely wrong. I'm stuck. Any and all help is appreciated. Thanks!

Best Answer

So, your requirement is, whenever the lookup field has any other user apart from Seller profile user, and the picklist is any of the 3 values, you need to throw a error.

So basically, validation rule will throw a error if, the condition evaluates to true.

You need to check if the profile is != Seller And If the picklist is any of the three values.

So in this case below code should work.

Try this:

AND( NewUser__r.Profile.Name != "Seller",
OR (
  ISPICKVAL(Style__c, 'Magazine'), 
  ISPICKVAL(Style__c, 'Digital'), 
  ISPICKVAL(Style_Type__c, 'Media') )
)