4

Hi i got a requirement like create a validation rule based on probability.

The requirement is user cannot modify some custom field called forecast units If probability is under 70%

So, i write a validation rule like

AND(ISCHANGED( Forecast_Units__c ),Probability < 0.70)

It works fine but when i create any opportunity the validation doesn't work can anyone help me

3 Answers 3

11

According to the docs

ISCHANGED function returns FALSE when evaluating any field on a newly created record.

So your validation will never fire when you are creating a record. You might want to add ISNEW() function which checks if you are creating a new record.

OR(
   AND(ISNEW(), NOT(ISBLANK( Forecast_Units__c )), Probability < 0.70),
   AND(ISCHANGED( Forecast_Units__c ),Probability < 0.70)
)
3

That is because the validation will only fire on the field being changed. To make it work on creation you would need to use ISNEW

So I think the following will work updated based on Adrian's input and checking that Forecast_Units__c is populated.

 AND(Probability < .7, 
    OR(AND(ISNEW(),NOT(ISBLANK( Forecast_Units__c ))), 
       ISCHANGED(Forecast_Units__c)))
3
  • You missed a comma(,) between two and conditions as the template for OR is OR(condition1,condition2,...conditionN) Commented May 11, 2016 at 19:49
  • 1
    Would be more elegant (and more importantly, lower compile size) as AND(Probability < .7, OR(ISNEW(), ISCHANGED(Forecast_Units__c))). DRY.
    – Adrian Larson
    Commented May 11, 2016 at 19:58
  • 4
    This formula would stop a user from creating a new opportunity with < 70% probability. I would guess this is not the intended behavior. Not clear from the original question if forecast units should be blank on creation or some pre-determined value.
    – Jimmy Jay
    Commented May 11, 2016 at 20:00
0

EDIT: This validation below is incorrect, the only thing you can learn from it is how to DO NOT USE a combination of ISNEW() and ISCHANGED() formulas in Validation Rules ))

AND(
 NOT( ISNEW()),
 ISCHANGED( Forecast_Units__c ),
 Probability < 0.70
)

Would allow you to bypass this validation when new record is created.

2
  • 1
    When new record is created his validation never fires, because ISCHANGED() always returns false. Commented May 12, 2016 at 8:15
  • @OlesMalkov You are right
    – o-lexi
    Commented May 12, 2016 at 16:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .