[SalesForce] Add a Profile Exception to Validation Rule

I have written a Validation Rule that I need to include a profile exception in. My rule is below and I can't figure out how to add an exception so that System Administrators can bypass this rule. Can someone please help me add in the Sytem Administrator exception. Thanks!

My rule is: If a field equals a certain value, another field (multi select picklist) cannot have a certain value removed from it unless you are a system admin.

Please see Rule below:

if( Field__c == 'Value', 
  if( 
    OR( 
      INCLUDES(Custom_Field__c,'Value') 
    ), 
    True, 
    False 
  ), 
False 
)

Best Answer

Checking by profile should not be done these days. It's inflexible, and doesn't allow you to respond quickly to changes. Instead, use a custom permission. First, create a new custom permission. Second, assign it to the profile(s) you want to exempt from your validation rule. Third, create your validation rule, which might look like this:

AND(NOT($Permission.Allowed_To_Do_Something),
    Field__c == 'value', 
    INCLUDES(PRIORVALUE(Other_Field__c),'value'),
    NOT(INCLUDES(Other_Field__c, 'value')))

This says: "If the user does not have permission to bypass this rule, and the first field is a specific value, and the multi-select picklist value previously contained a value, and the multi-select list no longer contains this value, trigger this validation rule."

Edit: edited based on rule description. Please feel free to adjust.

Related Topic