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
etessetess 

Rule for Who Can Change an Opportunity Owner

I would like to create a validation rule that permits only Standard Users or Opportunity Owners to be able to change the ownership of an Opportunity. I created the following Validation rule on Opportunity owner:

 

 

AND(ISCHANGED( OwnerId ) , NOT(OR($Profile.Name == 'Standard User', OwnerId == $User.Id )))

 

 

However, it's not working. My test (on a System Admin profile) was to change an Opportunity not owned by me to me. I think it is failing because OwnerId is refering to the NEW value of the Opportunity Owner field, rather than the old value.

 

How do I get this working?

Best Answer chosen by Admin (Salesforce Developers) 
Steve :-/Steve :-/

Give this one a try

 

AND(
ISCHANGED(OwnerId),
PRIORVALUE(OwnerId) <> $User.Id,
NOT($Profile.Name = "System Administrator"))

 

 

All Answers

Steve :-/Steve :-/

Give this one a try

 

AND(
ISCHANGED(OwnerId),
PRIORVALUE(OwnerId) <> $User.Id,
NOT($Profile.Name = "System Administrator"))

 

 

This was selected as the best answer
etessetess

Aha! It was that PRIORVALUE function I was looking for. Thank you

Steve :-/Steve :-/

No problem, you owe me a beer!   Oh yeah, and I like to drink these->