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
Shauna LismoreShauna Lismore 

Exclude a profile from a validation rule

Hi everyone,

We have a 'Rune rate' field which needs to be locked after it has been populated. I've figured that out with this validation rule:

AND(
ISCHANGED(Run_Rate__c),
NOT(ISBLANK(PRIORVALUE(Run_Rate__c)))
)
​​​​​​
Now i'm trying to exclude the system admin profile from this. I've tried using 

NOT($Profile.Name = "System Administrator")

but I'm not sure where to put it as I keep getting the 'missing )' error. Any ideas?

(I'm very new to formulas!)
Best Answer chosen by Shauna Lismore
Gian Piere VallejosGian Piere Vallejos
$Profile.Name = 'System Administrator' is not working because the default language set, you should use the $Profile.Id and the validation rule should be: 
ISCHANGED(Run_Rate__c) && NOT(ISBLANK(PRIORVALUE(Run_Rate__c))) && $Profile.Id <> '00e6g000001MxdK'
My System Administrator's ID is: 00e6g000001MxdK (It can change). For get your Profile's ID, you can go to the Setup > Users > Profiles and select System Administrator profile. On the URL you will get the ID you were looking for.

Reference:  https://salesforce.stackexchange.com/questions/96189/profile-name-in-validation-rule-not-working

All Answers

Gian Piere VallejosGian Piere Vallejos
$Profile.Name = 'System Administrator' is not working because the default language set, you should use the $Profile.Id and the validation rule should be: 
ISCHANGED(Run_Rate__c) && NOT(ISBLANK(PRIORVALUE(Run_Rate__c))) && $Profile.Id <> '00e6g000001MxdK'
My System Administrator's ID is: 00e6g000001MxdK (It can change). For get your Profile's ID, you can go to the Setup > Users > Profiles and select System Administrator profile. On the URL you will get the ID you were looking for.

Reference:  https://salesforce.stackexchange.com/questions/96189/profile-name-in-validation-rule-not-working
This was selected as the best answer
Shauna LismoreShauna Lismore
Thanks Gian, that has worked perfectly.