$Profile.Name<> "Quality Sales Rep",
ISBLANK(ID__c)), True, False

This is a validation rule which should trigger on the user object when ID field is blank while creating a new user with the profile Quality Sales Rep. But the rule is triggering for all the other profiles. It must only trigger for profile " Quality Sales Rep"

  • Why are you not testing the profile name directly this will not include a profile of "Quality Sales Rep"?
    – Dave Humm
    Nov 30, 2020 at 12:30
  • It's working for the correct profile name Quality Sales Rep and also for profiles which contain Sales / Rep in the name
    – sfdc4321
    Nov 30, 2020 at 12:33

1 Answer 1


In a way, validation rules work the opposite way of how we programmers normally think.

If the conditions evaluate to true, the validation rule is tripped and prevents dml from ocurring on that record (and you'll either get a validation exception or an error noted in the database.saveresult if you are using allOrNone = false).

So if you want to enforce this rule (Id__c cannot be blank) only for the target profile, you need to use = instead of <>.

If [User has target profile] AND [Field is blank], then raise the error.

The true, false you have at the end should also be removed (adding a literal TRUE won't affect the outcome of the rest of the AND, while a literal FALSE will always cause the AND to return FALSE).


Got some clarification in the comments.

The goal here is different than I first thought. Instead of exempting a profile from the validation rule, this is meant to require a field on User to be filled when that User record has the target profile.

In that case, using $Profile is wrong. $Profile is a global variable (anything starting with $ is a global, and thus not based on the data of the record) giving you the profile of the user attempting to make a change to the record rather than the profile of the user record being inserted/updated.

What you want in this case is to check the profile of the user record itself. Profile.Name = 'Quality Sales Rep'

  • When I have changed the <> to = the rule is not working. It's allowing me to save the user when the field is blank. I have removed the true, false conditions
    – sfdc4321
    Nov 30, 2020 at 14:52
  • @sfdc4321 If the user you're testing this as doesn't have your target profile (Quality Sales Rep), then that is the expected result. If you need to prevent multiple profiles from doing this, then the information you provided in your question is inaccurate and should be updated.
    – Derek F
    Nov 30, 2020 at 15:02
  • actually, the rule has to be triggered when a system admin is creating a user with Quality Sales Rep profile. Here in this case rule is triggered only when you log in with Quality Sales Rep profile not with the System Admin profile
    – sfdc4321
    Dec 2, 2020 at 16:18
  • @sfdc4321 Ah, I had glossed over the fact that you were creating a new user record. I saw $Profile and my mind short-circuited to thinking you were trying to make an exclusion. Edited my answer to be more accurate.
    – Derek F
    Dec 2, 2020 at 16:42
  • Thank You, the rule is enforced now. As Profile is global variable used $ before it. I overlooked it, Thanks for clarificaion
    – sfdc4321
    Dec 2, 2020 at 16:46

You must log in to answer this question.

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