Validation rule closed won

I am new tot validation rules. I am trying to allow three users and the system Administrator profile to update and an Opportunity set to ‘Closed Won.’ No other users should be allowed update. My returns an error message when I login as one the three user who need to update. When I comment out the NOT line everyone can update. What am I not seeing?

AND(
  ISPICKVAL(Stagename, 'Closed Won'),
 NOT(
    OR(
         $User.Id = '005F000000431Qxxx1',
         $User.Id = '005F000000431Pxxx2',
         $User.Id = '005F0000005tuHxxx3',
         $Profile.ID = '00eF0000001B2gxxxC'
   ) 
 ) 
)

Also, do you know where I can find documentation to help me with Not, OR, etc. ?

Answer

I would just use != (not equals) instead of the NOT() function.

AND(
  ISPICKVAL(Stagename, 'Closed Won'),
  $User.Id != '005F000000431Qxxx1',
  $User.Id != '005F000000431Pxxx2',
  $User.Id != '005F0000005tuHxxx3',
  $Profile.ID != '00eF0000001B2gxxxC' 
)

Also, just to note, this not only prevents them from changing the status to Closed Won, but also prevents then from editing the opp once it is closed won. This may be what you want, in that case its fine. Just wanted to point it out in case you thought it was only preventing them from changing the stage to Closed Won.

Attribution
Source : Link , Question Author : G. Clak , Answer Author : Chris Duncombe

Leave a Comment