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
swain 10swain 10 

validation for restriction of field edit for particular profile and user

I have written one validation that some particular fields can only be edited by system admin or user should be record owner or User should be steve.
Please review It.

AND( OR(ISCHANGED( BusinessStrategy__c ),ISCHANGED(  BusinessStrategyComments__c )), OR( $Profile.Name  <> 'System Administrator'  &&   $User.Id  <>  OwnerId  &&   $User.Id  <> '005U0000001NqquIAC' ))

005U0000001NqquIAC is the user Id of steve because when I am giving $User.UserName='Steve' its throwing validation error even after using User Id still that user not able to edit.
PawanKumarPawanKumar
Please try below.

AND( OR(ISCHANGED( BusinessStrategy__c ),ISCHANGED(  BusinessStrategyComments__c )), OR( $Profile.Name  <> 'System Administrator',$User.Id  <>  OwnerId,$User.Id  <> '005U0000001NqquIAC' ))

Please let me know if it works for you.

Regards,
Pawan Kumar
Sanjay Bhati 95Sanjay Bhati 95

Hi  Swain 10 
 

Here is Sample of Validate Rule that fullfill your condition. Here I am checking Birthday field on contact object . If its change by user that is not a admin or owner of contact record then it will throw error.


OR((AND(ISCHANGED(Birthdate ), Owner.Profile.Name != $Profile.Name)),(AND(ISCHANGED(Birthdate), $Profile.Name != 'System Administrator')) )

please test and let me know

Regards 
Sanjay Bhati

PawanKumarPawanKumar
Please let me know. If it works for you.

Regards,
Pawan Kumar