function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kate Williams 24Kate Williams 24 

Validation rule to stop certain profile being assigned to field

I need to add a validation rule for if a certain profile is assigned to a Secondary AM field that it won't save. I don't want this profile to be able to be assigned to this field and so need an error message to pop up so people know not to assign certain users.
HarshHarsh (Salesforce Developers) 
Can you elaborate more on your requirements?
As per the description you want to show an error, the specific profile is not assigned to the  "Secondary AM" field i.e. Secondary_AM__C. 
If It is correct then please check the below 
  $Profile.Name = 'Profile Name',
  Secondary_AM__c <> NULL

If not, please specify your requirements a little more. 

Please mark it as Best Answer if the above-given validation was helpful.


Kate Williams 24Kate Williams 24

Hi, so yes, I don't want an SDR to be able to assigned to the Secondary AM field. I want it to stop the record from being saved and show the error message.

The formula you posted doesn't work - I'm still able to save a user who has the SDR profile.


HarshHarsh (Salesforce Developers) 
Let me confirm once,
if the profile is SDR and the value of " Secondary_AM__c" is SDR then it should throw the error.
Is it correct as per your requirement?
if yes then please try the below validation code snippet
AND($Profile.Name = 'SDR',
 Secondary_AM__c = 'SDR')

Please mark it as Best Answer if the above information was helpful.

Kate Williams 24Kate Williams 24
Yes that is correct for what I need. The snippet isn't working though. It's still letting me save the Secondary AM field with an SDR profile user.
HarshHarsh (Salesforce Developers) 
Can you share some screenshots of your validation rule and others related to the issue?
Kate Williams 24Kate Williams 24

I don't have any others related to this issue and it's not letting me attach a screenshot.
I have added into the validation rule formula window exactly as you entered it above



AND($Profile.Name = 'Sales Development Representative',
Secondary_AM__c = 'Sales Development Representative')

Steve :-/Steve :-/
Are you basically trying to create a Rule that will block a User from selecting a User with the 'SDR' User.Profile in a custom Lookup(User) field called Secondary AM?  Essentially a "Lookup Filter" (but a Validation Rule) 

Is that it?  or do I have it backwards/sideways/not at all?
Kate Williams 24Kate Williams 24
@Steve :-/. Yes, I want to block anyone from selecting a User with SDR profile from being assigned to the Secondary AM field.