1

I am trying to create a validation rule for Account. I want to limit the capability of the user to transfer the accounts (or changing de ownerID of the Account) . I only want them to be able to transfer Accounts to users that have the same role.

I am not being able to create the validation rule, this is sample of what I did but it is not working.

AND(
   ISCHANGED( OwnerId ),
   VLOOKUP($User.UserRole.name,$User.Id,PRIORVALUE(OwnerID)) = $UserRole.name
)

Thanks in advance for any tips.

1 Answer 1

1

You could create a formula field on the object that holds the Owner.UserRole.Name then use that in your validation rule like:

AND(
   ISCHANGED(OwnerId),
   PRIORVALUE(Owner_Role__c) <> Owner.UserRole.Name
)  

Which would only allow users to change the owner if the existing owner has the same Role as the new owner.

4
  • Thanks for your answer Jenny. I have tried to use your validation rules but I have the following error. Error: Field Owner_Role__c does not exist. Check spelling. Any ideas of what is wrong?
    – Dr. Xavier
    Commented Feb 3, 2015 at 16:32
  • @Dr.Xavier that was the name of the formula field I created first before creating the validation rule. Did you create a formula field resulting in Text and Owner.UserRole.Name as the formula? Whatever the api name is for that field is what should be set in the PriorValue function.
    – Jenny B
    Commented Feb 3, 2015 at 17:09
  • Thanks for the tips, I made it work. AND( ISCHANGED(OwnerId), PRIORVALUE( Onwer_Role__c ) <> Owner.UserRole.Name )
    – Dr. Xavier
    Commented Feb 4, 2015 at 10:42
  • @Dr.Xavier Updated the answer, I misunderstood the initial question but glad you got it working!
    – Jenny B
    Commented Feb 4, 2015 at 11:58

You must log in to answer this question.

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