Ask Search:
Lee MoreauLee Moreau 

Need help with a Lead validation rule, allow users to change the owner on Leads they own, but only Leads they own

Hi everyone, I need help doing the following rule:

- All user profiles can reassign a Lead that THEY own, to anyone else.
- If they do NOT own it, then they can view it, but they cannot edit it, change it, change the owner etc, UNLESS they are a System Administrator profile.

I need this as we have Lead Generation reps that create Leads and assign them, so they need to change the owner from themselves to a Sales Rep, but I don't want them to be able to go into another users Leads and reassign them to themselves, or change them at all.  Thanks!
Best Answer chosen by Lee Moreau
Rajesh Varma MudunuriRajesh Varma Mudunuri
If you want to check for prior value you can use 
AND(ISCHANGED( OwnerId ), PRIORVALUE(OwnerId) <> $User.Id)

 

All Answers

Rajesh Varma MudunuriRajesh Varma Mudunuri
Lee,
You can use a validation where $User.Id =  OwnerId condition to bass the validation
and $User.Id <> OwnerId condition for the validation rule to kick in
https://help.salesforce.com/articleView?id=000170713&type=1
AND(ISCHANGED( OwnerId ),$User.Id <> OwnerId)


Thanks.
Lee MoreauLee Moreau
Amazing thank you!!!
Rajesh Varma MudunuriRajesh Varma Mudunuri
If you want to check for prior value you can use 
AND(ISCHANGED( OwnerId ), PRIORVALUE(OwnerId) <> $User.Id)

 
This was selected as the best answer
Lee MoreauLee Moreau
Actually sorry it's not working at all the above..  AND(ISCHANGED( OwnerId ),$User.Id <> OwnerId) doesn't let me assign it to anyone, it gives an error.  If I do AND(ISCHANGED( OwnerId ),$User.Id = OwnerId) I can change it to anyone, but I can keep changing it as well which I don't want.  I also can't change it back to myself.  

I want it to be that you can only change the owner if you own the Lead, or are a System administrator.  I'll keep looking but unfortunately the above doesn't work.
Lee MoreauLee Moreau
That second one seems to work!
Rajesh Varma MudunuriRajesh Varma Mudunuri
Yeah you still need to add the admin condition 
AND(ISCHANGED( OwnerId ),
NOT(OR($Profile.Name = "System Administrator",PRIORVALUE(OwnerId) = $User.Id)) )