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
Mr. KarateMr. Karate 

Help with a Validation Rule

I want to Create a  Validation Rule that Disallows Users taking ownership of records if they Are in the Same Role 

 

Example 

 

User A and User B are in the Same Role, So User B can't take ownership of records that are in User A's possession. 

 

Admins and Manager are able to take ownership though. 


Thanks in Advance 

Jeff TalbotJeff Talbot

I have not tried the approach I am about to suggest. I'm taking a guess so I get good karma and hopefully get an answer to a question I just posted. haha.

 

  1. Create a custom field "Owner Role ID".
  2. Create a workflow rule to recognize when the owner is changed - formula value ISCHANGED(OwnerId)
  3. Create a a workflow action field update that populates the "Owner Role ID" custom field - formula value Owner.UserRoleId
  4. Create a validation rule to check if the Owner Role ID is changed and if so, check if the current value and prior value are the same:

AND(
         ISCHANGED(Owner_Role_ID__c),
         Owner_Role_ID__c = PRIORVALUE(Owner_Role_ID__c)
       )

 

There's a bit gotcha. You'd need mass update all records whenver you change a User's role. If you don't, the data will be whacked and the rule will not work as intended/desired, probably causing your Users to hunt you down and/or start stealing your lunch from the refrigerator.

kevin lamkevin lam

Create a validation rule with this error condition formula:

AND(ISCHANGED(OwnerId),
    $Profile.Name <> "System Administrator",
    $User.Id <> Owner.ManagerId,
    Owner.UserRoleId = $User.UserRoleId)