4

Below is my Validation Rule. It does not allow a user with the Profile of 'management' to change the owner of a record.

AND (
    ISCHANGED(OwnerId), 
    OR(
        PRIORVALUE (OwnerId ) <> $User.Id,
        $Profile.Name  <>  'Sales Administrator',
        $Profile.Name  <>  'Management',
        $Profile.Name  <>  'System Administrator'
    )
)
6
  • Have you tested this for the other profiles listed in this validation rule?
    – cmmoutes13
    Jul 27 '16 at 15:33
  • Guess it only works for the system admin, the other two profiles display the error message from the validation rule.
    – Nicole Ard
    Jul 27 '16 at 15:42
  • First thing that I would try is using the ID's instead of the name, it eliminates the possibility of spelling errors. Then I would try and just test one profile at a time. Remove the others from the validation rule, run the first and if it works then add the next and test it, and then keep going till you find the first one that doesn't work.
    – cmmoutes13
    Jul 27 '16 at 15:43
  • Nooooo not hard-coded Ids. :(
    – Adrian Larson
    Jul 27 '16 at 15:49
  • Adding just the Sales Administrator and using the ID# vs the Profile name did not allow a user with that profile type to make the change. But removing the system admin did prevent me from making a change as a system admin.
    – Nicole Ard
    Jul 27 '16 at 15:49
2

You will always not be one of those profiles, since you can only have one. It sounds like what you want is to throw an error if your first criterion is true (owner has changed) and none of the subsequent criteria are true (running user is either current owner or whitelisted profile). In that case, use NOT(OR(...)) with equality comparisons, instead of OR(...) with inequality comparisons.

AND(
    ISCHANGED(OwnerId),
    NOT(OR(
        PRIORVALUE(OwnerId) = $User.Id,
        $Profile.Name = "System Administrator",
        $Profile.Name = "Sales Administrator",
        $Profile.Name = "Management"
    ))
)
7
  • I want the listed profiles to be the only users that can change the ownership. I replaced the provided code and it still shows the validation error for a user of the Management profile, but does allow the system admin to change ownership without an error.
    – Nicole Ard
    Jul 27 '16 at 15:59
  • Correction, I can change only if I am the owner already, so the first part of the rule is working.
    – Nicole Ard
    Jul 27 '16 at 16:02
  • I think I see what's going on. Perhaps I misinterpreted what is going on with PRIORVALUE. You want these select profiles to be able to change owner even if they aren't the current owner? @NicoleArd
    – Adrian Larson
    Jul 27 '16 at 16:04
  • I'll add more explanation if the current rule is actually what you're looking for.
    – Adrian Larson
    Jul 27 '16 at 16:09
  • Correct, basically limit the ability from anyone from changing the ownership of the record
    – Nicole Ard
    Jul 27 '16 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.