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
Selvakumar Anbazhagan 7Selvakumar Anbazhagan 7 

Issue in Validation Rule for Opportunity Edit

Hi All,

I have created a validation rule in Opportunity that some profile users doesn't edit opportunity which he not owns. Meanwhile, some users should still be allowed to make changes to any Opportunity, even if they don’t own it (e.g. System Administrator, Sales Directors).  However, the way this validation code is currently written, it restricts ALL users who aren’t the owner.  

My validation rule is given below.
AND( 
OR( 
Owner.Profile.Name = "Account Executive", 
Owner.Profile.Name = "Inbound Sales", 
Owner.Profile.Name = "Outbound Sales", 
Owner.Profile.Name = "Commercial Bulk Executive" 
), 
Owner.Id <> $User.Id 
)


Can anyone suggest me how to acheive it?

Thanks in advance.
Best Answer chosen by Selvakumar Anbazhagan 7
William TranWilliam Tran
The concept is good, but you are basing the profile on the owner not user.

Try this and Admin will have access, but you can tweak as needed.
 
AND( 
OR( 
$Profile.Name = "Account Executive", 
$Profile.Name = "Inbound Sales", 
$Profile.Name = "Outbound Sales", 
$Profile.Name = "Commercial Bulk Executive" 
), 
Owner.Id <> $User.Id 
)

this will restrict if you are not owner and you are one of these 4 roles.

All other roles  (e.g. System Administrator, Sales Directors) can still edit.

Be sure to mark best answer if your question is answer.

Thx

All Answers

William TranWilliam Tran
The concept is good, but you are basing the profile on the owner not user.

Try this and Admin will have access, but you can tweak as needed.
 
AND( 
OR( 
$Profile.Name = "Account Executive", 
$Profile.Name = "Inbound Sales", 
$Profile.Name = "Outbound Sales", 
$Profile.Name = "Commercial Bulk Executive" 
), 
Owner.Id <> $User.Id 
)

this will restrict if you are not owner and you are one of these 4 roles.

All other roles  (e.g. System Administrator, Sales Directors) can still edit.

Be sure to mark best answer if your question is answer.

Thx
This was selected as the best answer
Selvakumar Anbazhagan 7Selvakumar Anbazhagan 7
Hi William Tran,

Thanks a lot. Its working fine,which you have done. Great help!!