0

Is there a way to retrieve the current user in a validation rule?

The logged in user will be logging in from a community.

Need to make the record only editable if the Logged in user matches the Look up field on the record.

This is for multiple users. So cannot explicit put the user.id in the rule

Thanks

4
  • 5
    Possible duplicate of Validation should not fire for a specific user
    – martin
    Commented Mar 29, 2016 at 1:36
  • I think what @Yandel wants is to validate the current user based on a user lookup field within an object. So this needs to be dynamic instead of using a single User Id for validation.
    – sfdx
    Commented Mar 29, 2016 at 2:18
  • @SeanSoriano exactly what is required.
    – Yandel
    Commented Mar 29, 2016 at 2:19
  • @SeanSoriano Good catch.
    – martin
    Commented Mar 29, 2016 at 3:35

1 Answer 1

2

If your Lookup field is a user, this can easily be done by creating a validation rule that will check for the current user's id and the lookup field's id.

Here's a sample validation rule that compares the records owner(user lookup) with the current user's id. The validation will fire if the User Id is not equal to the owner of the record. Just replace the OwnerId with your own User lookup field.

 $User.Id <>  OwnerId 

You must log in to answer this question.

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