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

10

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)
)
| improve this answer | |
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)))
| improve this answer | |
  • You missed a comma(,) between two and conditions as the template for OR is OR(condition1,condition2,...conditionN) – Vigneshwaran G May 11 '16 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 May 11 '16 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 May 11 '16 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.

| improve this answer | |
  • 1
    When new record is created his validation never fires, because ISCHANGED() always returns false. – Oles Malkov May 12 '16 at 8:15
  • @OlesMalkov You are right – o-lexi May 12 '16 at 16:39

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.