I need help with my Validation Rule. In my scenario, I have one Custom Object and in the Custom Object, I have one "Record Owner" Field which is lookup through the User Object. I want only that user edit that record which is assigned to him and that record "Read Only" for others. Also, I have Some Profiles, Those Profiles have access to all the records which is assigned or not. Here's my Validation Rule:-

        CONTAINS( $User.ProfileId , 'ID'),
        CONTAINS( $User.ProfileId , 'ID'), 
        CONTAINS( $User.ProfileId , 'ID'),
        CONTAINS(  Record_Owner__r.Alias ,  $User.Alias )

From this Validation Rule, I got the error when the other Profile User trying to update that Record which has access for all the Records.

Thank you in advance

2 Answers 2


You should be using a Custom Permission. Your validation could then look like:

Not(Or($Permission.EditObjectXRecords, $User.Id = OwnerId))

Alternately, consider setting your Organization Wife Defaults to Read Only, then assign the Modify All Data (Object X) permission to the profiles or a Permission Set.

  • Hey @sfdcfox, I didn't get your point, Can you explore it? I want to Assign the profiles, not the user. So how can I create a Permission Set for this condition? Oct 12, 2019 at 6:02
  • @PratyanchRajput Custom Permissions can be assigned to a Profile or Permission Set. You can then assign the permission to those three profiles. The validation rule checks just for the permission being set on the profile or a Permission Set for the user. The second part of the validation rule checks to see if the user owns the record.
    – sfdcfox
    Oct 12, 2019 at 6:20

There is a standard field for record owner that you can use. If I understand correctly, you want only the record owner to be able to edit the record. In that case, your Error Condition Formula would be simply

$User.Id  <>  OwnerId

To include Profiles, consider the solution from @sfdcfox. It means that you do not need to consider changes to Profile name, or different Ids in each sandbox for a new Profile until it is refreshed from Production.

If you choose not to, go to the Profile(s) that should be able to edit the record and get the Id of the Profile. Include them in the formula like this:

    $User.Id  <>  OwnerId,
    $Profile.Id <> '00e30000001Ja3e',
    $Profile.Id <> '00e30000001Gs8e',
    $Profile.Id <> '00e30000001aFo2'

Using Profile Id is safer than using the name of the Profile since the name can be edited. If the Profiles that you want to include were already in Production when your sandbox was created, the Profile Id will be the same as it is in Production, so no need to modify the VR in each sandbox.

  • Hey Mike, Also I want to give Permission for some of the Profiles (Admin). Oct 12, 2019 at 5:50
  • This condition is given the record edit permission only for the record owner but I want the admin has to edit access all the records. Oct 12, 2019 at 6:09

You must log in to answer this question.

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