Ask Search:
David ShieldsDavid Shields 

Help with a validation rule

I have a validation rule preventing only certain users from editing Account names.  I am trying to edit it. I am trying to edit this so the user ID identified in the rule can only edit Opportunities that she owns. The rule is as follows:

IF( 

OR($UserRole.Name='CEO', 
$UserRole.Name='CFO', 
CONTAINS($UserRole.Name,'Administrator'), 
CONTAINS($User.Id,'00550000006eC5l'), 
AND(CONTAINS($UserRole.Name,'ALVS'), Top_Level_Account__r.Name='ALVS Administration', 
NOT(CONTAINS(Name,'ALVS')))), 

False, 

AND(ISCHANGED(Name),NOT(ISNEW())))

I am trying to edit this so the user ID identified in the rule can only edit Opportunities that she owns. 
 
Best Answer chosen by David Shields
Sathishkumar PeriyasamySathishkumar Periyasamy
If based on owner id. please try below rule 
 
AND(ISCHANGED(Name), NOT(ISNEW())
$User.Id != OwnerId
)

If works for you then you can add OR conditon to skip certial user and roles.

All Answers

Sathishkumar PeriyasamySathishkumar Periyasamy
David, Can you please try this
 
IF(OR($UserRole.Name='CEO', 
$UserRole.Name='CFO', 
CONTAINS($UserRole.Name,'Administrator'), 
$User.Id ="00550000006eC5l", 
AND(CONTAINS($UserRole.Name,'ALVS'), 
Top_Level_Account__r.Name='ALVS Administration', 
NOT(CONTAINS(Name,'ALVS')))), 

False, 

AND(ISCHANGED(Name),NOT(ISNEW())))
Geoffrey FlynnGeoffrey Flynn
Wouldn't it make more sense to split that into two validation rules?  Don't be scared of having multiple rules - it makes messaging to end users a lot easier because you can be more specific about why they aren't allowed to do what they are trying to do
David ShieldsDavid Shields
Thanks Sathiskumar but this does not prevent this user from editing an Account she does not own. That is what I was trying to get to
David ShieldsDavid Shields
Thanks Geoffry, that is where I was leaning. 
Sathishkumar PeriyasamySathishkumar Periyasamy
David, are you using OwnerID to detrimine wheter user owning record?
Sathishkumar PeriyasamySathishkumar Periyasamy
If based on owner id. please try below rule 
 
AND(ISCHANGED(Name), NOT(ISNEW())
$User.Id != OwnerId
)

If works for you then you can add OR conditon to skip certial user and roles.
This was selected as the best answer
Sunil SarillaSunil Sarilla
+ Geoffrey
I would split this into 2 Validation rules instead of bundling them into one rule.
If you decided to go with the 2 separate validation rules, the second validation rule will be as below
AND(
ISCHANGED(Name),
NOT(ISNEW()),
$User.Id ='00550000006eC5l',
OwnerId <> $User.Id
)
Instead of hardcoding the ID of the User, use some thing like Username or Alias.

If you want to go ahead with one rule, the syntax will be as below
IF(
OR(
$UserRole.Name='CEO', 
$UserRole.Name='CFO', 
CONTAINS($UserRole.Name,'Administrator'), 
AND($User.Id='00550000006eC5l',$User.Id <> OwnerId), 
AND(
CONTAINS($UserRole.Name,'ALVS'), 
Top_Level_Account__r.Name='ALVS Administration', 
NOT(CONTAINS(Name,'ALVS'))
)
),
False,
AND(
ISCHANGED(Name),
NOT(ISNEW())
)
)