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
Shahil Khan 1Shahil Khan 1 

Validation rule to restrict users with a certain profile to update field called "Lead Source"

I have a few users under profile "SDR" who i want to restrict from editing a particular field called "Lead Source". How would i go about writing a validation rule where any users where the users profile CONTAINS "SDR" should not abe allowed to update/edit the field under no circulstances. 
Best Answer chosen by Shahil Khan 1
NagendraNagendra (Salesforce Developers) 
Hi Khan

I tested this and it works for me:

Please tweak the below validation rule as per your lead source picklist value.
$Profile.id="xxxxxxx" && not(ispickval(leadsource, "web")) && ( ischanged(leadsource) || isnew() 
1. It prevents specific profile user to select other picklist values when editing this lead source field
2. prevent specific profile user to select other picklist values when creating a new lead

$Profile
Description: A global merge field type to use when referencing information about the current user's profile. Use profile merge fields to reference information about the user's profile such as license type or name.

Use:
Select the field type: $Profile.
Select a merge field such as $Profile.Name.

Hope this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra

All Answers

NagendraNagendra (Salesforce Developers) 
Hi Khan

I tested this and it works for me:

Please tweak the below validation rule as per your lead source picklist value.
$Profile.id="xxxxxxx" && not(ispickval(leadsource, "web")) && ( ischanged(leadsource) || isnew() 
1. It prevents specific profile user to select other picklist values when editing this lead source field
2. prevent specific profile user to select other picklist values when creating a new lead

$Profile
Description: A global merge field type to use when referencing information about the current user's profile. Use profile merge fields to reference information about the user's profile such as license type or name.

Use:
Select the field type: $Profile.
Select a merge field such as $Profile.Name.

Hope this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra
This was selected as the best answer
Shahil Khan 1Shahil Khan 1
Thanks for the swift reponse Nagendra! Your suggested VR worked like a charm
Arnold WaltersArnold Walters
Hi! Thank you very much Nagendra! I was struggling with the validation rules until I found your great contribution. Thanks again!