Skip to main content
We recently had to create a validation rule to make a field "actual_weights__c) required depending on certain circumstance and were having problems with getting it working because of using NOT(ISPICKVAL to say we do not want it to equal certain values so I'm wondering if someone can help explain the difference.  The working validation rule is:

 

AND( 

 

OR( 

 

ISPICKVAL(Type__c, "ValueA"), 

 

ISPICKVAL(Type__c, "ValueB"), 

 

ISPICKVAL(Type__c, "ValueC"), 

 

), 

 

OR( 

 

ISPICKVAL(OtherType__c, "Value2"), 

 

ISPICKVAL(OtherType__c, "Value4"), 

 

ISPICKVAL(OtherType__c, "Value6") 

 

), 

 

Owner:Queue.Name = "Person", 

 

NOT(ISBLANK(C_W__c)), 

 

ISBLANK(Actual_Weights__c) 

 

)

 

but for the 2nd OR statement above, we wanted to write:

 

NOT(ISPICKVAL(OtherType__c, "Value1")), 

 

NOT(ISPICKVAL(OtherType__c, "Value3")), 

 

NOT(ISPICKVAL(OtherType__c, "Value5")), 

 

but when we had this syntax in the rule, no matter what the value we picked for OtherType__c, we would always get the validation error message until we populated actual_weights__c.  The reason we wanted to do it this way is because there's about 15 values in the picklist and the "not" values is only 3, so instead the rule has to specify 12 values.  Just want some clarification for the future.  Thanks!
2 respuestas
  1. 16 feb 2018, 22:45
    Hi Scott,

     

    the Syntax for NOT ISPICKVAL is right but you need to wrap them AND statement not OR 

    AND(

    OR(

    ISPICKVAL(Type__c, "ValueA"),

    ISPICKVAL(Type__c, "ValueB"),

    ISPICKVAL(Type__c, "ValueC"),

    ),

    NOT(ISPICKVAL(OtherType__c, "Value2")),

    NOT(ISPICKVAL(OtherType__c, "Value4")),

    NOT(ISPICKVAL(OtherType__c, "Value6")),

    Owner:Queue.Name = "Person",

    NOT(ISBLANK(C_W__c)),

    ISBLANK(Actual_Weights__c)

    )

     SteveMo has a great explanation on why OR and NOT does not work together on the same field

     

    refer to the follwing link for the same
0/9000