0

My validation rule, I am playing around. Should activate only when June 15/2018 or June 16 2018. But it activates for any date. Not sure why.

OR(ISPICKVAL( StageName , "1 - Prospect"), 
ISPICKVAL( StageName , "2 - Strategy/Proposal Generation"), 
ISPICKVAL( StageName , "3 - Proposal Submitted"), 
ISPICKVAL( StageName , "4 - Negotiation") ) && 
OR(RecordTypeId ="008xzZ",RecordTypeId ="001ZUOX") && OR( 
DATE( YEAR(CloseDate),MONTH(CloseDate),DAY(CloseDate)) <> DATE(2018,6,15), 
DATE( YEAR(CloseDate),MONTH(CloseDate),DAY(CloseDate)) <> DATE(2018,6,16))
1

Validation rules go off if they evaluate to true. The salient portion of your formula:

OR( 
   DATE(YEAR(CloseDate),MONTH(CloseDate),DAY(CloseDate)) <> DATE(2018,6,15), 
   DATE(YEAR(CloseDate),MONTH(CloseDate),DAY(CloseDate)) <> DATE(2018,6,16)
)

will evaluate to true for any date other than 2018-06-15 and 2018-06-16. You need to simply invert the logic by changing <> to =. (Also, CloseDate is already a Date value).

As an aside, formulas become incredibly hard to read when you mix && operator style and OR() function-style logic. Sticking with one style and using indentation to show the level of nesting helps make the formula more readable.

3
  • 1
    Spot on, and don't forget to use references for those recordtype names instead of hard-coding the IDs.
    – JaredT
    Jun 8 '18 at 19:29
  • Can i use CEILING(MONTH(TODAY())/3) to get march, june, september, december?
    – nameishi
    Jun 8 '18 at 19:32
  • I don't really follow, @nameishi, but that sounds like a separate question.
    – David Reed
    Jun 8 '18 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.