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
Carrlos BoydCarrlos Boyd 

Validation rule that only record owner can edit record (except System Administrator)

I need a validation rule that only allows the owner of a record, or System Administrator, to edit the record.
Raj VakatiRaj Vakati
AND( $User.Id <> OwnerId,
 $Profile.Name <> "System Administrator",
ISCHANGED(Field__c),
 )
Sagar PatilSagar Patil
Try this,
AND 
( 
 NOT(ISNEW()), 
 OR( 
       $Profile.Name <>'System Administrator', 
       $User.Id <> OwnerId 
      ) 
)

 
Raj VakatiRaj Vakati
Yes .. Sagar, you are correct! 
Carrlos BoydCarrlos Boyd
Sagar, it is working for the owner but for some reason a System Administrator still cannot edit the record.
Sagar PatilSagar Patil
1. Can you check the object permission associated system Administrator profile for that particular object. Check whether if it has Edit permission. This may be the reason, admin can't edit object record.

2. Create permission set and provide edit access to system administrator profile and test.

3.Please ensure that you are logged in as system administrator because generally admin has access to all objects

4. If it doesn't solve your issue, can you share error message screenshot.
Carrlos BoydCarrlos Boyd
I checked and System Administrator has permissions to edit the object as well as read, create, and delete. What about Raj V's code. Maybe I should try it?
Sagar PatilSagar Patil
Please ensure that profile name in validation rule is correct. Is it System Administrator only.

Replace profile name with its id in validation rule. Profile Id will be present in URL. You can refer below sample code.
$Profile.Id <> '00e36000000ZQXB'

Refer this link.
https://salesforce.stackexchange.com/questions/96189/profile-name-in-validation-rule-not-working 
 
Shruti Vaishya 4Shruti Vaishya 4
IF((ISNEW()!= TRUE),
OR
(
ISNEW(),
AND(
$Profile.Name <>'System Administrator',
$Profile.Name <>'Manager',
$User.Id <> CreatedById
)
),
FALSE
)
Faith ChryslerFaith Chrysler
I am currently trying to use this validation rule. It works great, but there is still a problem. My SDRs create opportunities and then trasnfer them to an AE. When they go to transfer it into someone else's name, the error pops up that they need to be the opportunity owner to transfer the record, but they are the owner. help!