Skip to main content
Can someone look at it and suggest what is wrong with this validation rule. It is not simply not working. It is on validation rule where if Profile does not match to the given two profiles and if status is either Ready or Sent and if ticket prior value does not match, throw an error.

 

AND ( 

 

OR ( $Profile.Name <> "System Administrator", $Profile.Name <> " Integration User"), 

 

OR (Status__r.Name ='Ready', Status__r.Name ='Sent' ), 

 

PRIORVALUE (Ticket__c) > Ticket__c 

 

)
3 answers
  1. Oct 4, 2017, 8:29 PM

    Use AND not OR

    AND (

    CASE( $Profile.Name ,

    "System Administrator", 1,

    "Integration User", 1,

    0) = 0,

    CASE(Status__r.Name ,

    'Ready', 1,

    'Sent', 1,

    0 ) = 1,

    PRIORVALUE (Ticket__c) > Ticket__c

    )

     

    You don't want to use an OR statement with NOT or <> like that.  A field like $User.Id, $Profile.Id, $Profile.Name, etc. can only hold 1 value at a time.  

     

    Any User can only have 1 UserId, 1 Profile, 1 Role, etc

     

    So for example if:

     

    Moe has $Profile.Name = X

     

    Larry has $Profile.Name = Y

     

    Curly has $Profile.Name = Z

     

    Joe has $Profile.Name = Q

     

    And we want to block any other User with Profile <> X, Y, Z from doing something.  If your Formula uses Logic like this:

     

    OR(

     

    $Profile.Name <> "X",

     

    $Profile.Name <> "Y",

     

    $Profile.Name <> "Z",

     

    )

     

    Joe is blocked because Q is <> X or Y or Z

     

    great!

     

    BUT...

     

    Moe is also blocked because X is <> Y or Z

     

    Larry is also blocked because Y is <> X or Z

     

    Curly is also blocked because Z is <> X or Y

     

    So now every User is blocked, not just the one's you want (and that's not so great)

     

    Unless the User is Schrodinger's Cat, then all bets are off...

     

    Use AND not ORAND ( CASE( $Profile.Name ,

     

     
0/9000