0

I have a dummyCheckbox in my Opportunity Object which is set to false. Now in my Validation rule I set my dummyCheckbox to True so that the validation should not run but in my experience it is still running. Can someone help me?

This is my Validation Rule.

AND(
    HasOpportunityLineItem,
    dummyCheckbox__c  =  True, 
    (
        (ISCHANGED( Total_List_Price__c))  || 
        (ISCHANGED( Total_End_User_Price__c)) ||
        (ISCHANGED( Total_End_User_Price_Discount__c)) || 
        (ISCHANGED( Total_Standard_Price__c)) || 
        (ISCHANGED( Total_Standard_Price_Discount__c)) ||
        (ISCHANGED( Total_SPR_Price__c)) || 
        (ISCHANGED( Total_SPR_Price_Discount__c)) || 
        (ISCHANGED( Total_Price__c)) || 
        (ISCHANGED( Total_Price_Discount__c)) ||
        (ISCHANGED( Total_SPR_Margin__c))
    )
)

I also Tried doing dummyCheckbox__c == True,

2
  • How did you set the checkbox value to false. or it is already false before you edit the record. Oct 26, 2016 at 16:33
  • @TusharSharma The default value of the dummyCheckbox__c is unchecked or false.
    – JMDF
    Oct 26, 2016 at 17:28

1 Answer 1

2

First note: It isn't possible to do assignment in validation rules. In validation rules, the single equals sign = performs an equality comparison. As far as I know, this is true for all declarative formulae in Salesforce (workflow formulae, formula fields, etc...)

You cannot completely prevent any (active) validation rule from running. The best we can do is to cause the validation rule to short-circuit1, preventing a portion of the validation rule from being evaluated (As a side note, one of the first answers that I gave on this site would appear to confirm that formulae are evaluated in a lazy fashion).

So while the validation rule will run partially, if your Opportunity has dummyCheckbox set to false, your validation rule (as is) should not end up preventing you from saving changes to an Opportunity where one of your target fields is changing.

1:By short-circuit, I mean that if you have a situation where the end result of a Boolean expression can be known before evaluating all of the statements, Salesforce will stop the evaluation as soon as it can. false && <some other expression> will always end up being false, so there's no point to continuing the evaluation.

1
  • Profiling validation rule execution time... genius!
    – sfdcfox
    Oct 26, 2016 at 16:30

You must log in to answer this question.

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