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
VashnarVashnar 

Lock Oppty based on one of two picklist values, except Admins

Trying to lock editing on Opptys if they have one of two picklist values selected. Also need to except Admins from the rule.

 

My current attempt:

 

AND( 
ISPICKVAL(Status__c,"Active"), 
ISPICKVAL(Status__c,"Expired"), 
NOT($Profile.Id = "00e80000000zMnI") 
)

 

Thanks in advance!

Brian

Best Answer chosen by Admin (Salesforce Developers) 
@anilbathula@@anilbathula@
Hi Vashnar,

try this validation rule:-

AND( OR(
ISPICKVAL(Status__c,"Active"),
ISPICKVAL(Status__c,"Expired")),
NOT($Profile.Id = "00e80000000zMnI")
)

All Answers

@anilbathula@@anilbathula@
Hi Vashnar,

try this validation rule:-

AND( OR(
ISPICKVAL(Status__c,"Active"),
ISPICKVAL(Status__c,"Expired")),
NOT($Profile.Id = "00e80000000zMnI")
)
This was selected as the best answer
rbohnrbohn

Think you might want.....

 

OR( 
        ISPICKVAL(Status__c,"Active"), 
        ISPICKVAL(Status__c,"Expired")

       ) &&
NOT($Profile.Id = "00e80000000zMnI") 

ashishkrashishkr

Using hard-coded values is a bad practice. Use $Profile.Name instead, as below:

 

AND( OR(
ISPICKVAL(Status__c,'Active'),
ISPICKVAL(Status__c,'Expired')),
NOT($Profile.Name = 'System Administrator')
)

VashnarVashnar

I thought the Profile ID was better practice as it will not change, but the Profile Name could change and break the validation rule

VashnarVashnar

Thanks!

ashishkrashishkr

You cannot change the "System Administrator" profile name. 

In a typical business environment, the profile names would be all fixed and never change. The development would actually happen on multiple sandboxes. The components would then be moved to production through changesets. As such, the profile ids would keep changing for each sandbox and production. But the name remains the same.